Message posté par : Marion Robin
----------------------------------------
Bonjour,
Il y a la fonction Shapely nearest_points qui fait ça. Je viens de tester et ça a
l'air de plutôt bien fonctionner :-)
import geopandas as gpd
from shapely.geometry import Polygon, Point
from shapely.ops import nearest_points
poly = Polygon([(4.338074,50.848677), (4.344961,50.833264), (4.366227,50.840809),
(4.367945,50.852455), (4.346693,50.858306)])
poly = gpd.GeoSeries(poly, crs='EPSG:3395')
point = gpd.GeoSeries([Point(4.382617,50.811948)], crs='EPSG:3395')
nearest_edge, _ = nearest_points(poly[0], point[0])
nearest_edge = gpd.GeoSeries(nearest_edge, crs='EPSG:3395')
ax = poly.plot()
point.plot(ax=ax, color='red')
nearest_edge.plot(ax=ax, color='green')
----------------------------------------
Le message est situé
https://georezo.net/forum/viewtopic.php?pid=356626#p356626
Pour y répondre : geolibre(a)ml.georezo.net ou reply de votre messagerie
Pour vous désabonner connectez-vous sur le forum puis Profil / Abonnement
--
Association GeoRezo - le portail géomatique
https://georezo.net