Vous devez faire ce que vous dites. Pour cela, vous devrez utiliser une bibliothèque qui gère les projections (pyproj
est le choix ici). Il y a une question similaire dans Geodesic buffering in python
import pyproj
from shapely.geometry import MultiPolygon, Polygon, Point
from shapely.ops import transform as sh_transform
from functools import partial
wgs84_globe = pyproj.Proj(proj='latlong', ellps='WGS84')
def point_buff_on_globe(lat, lon, radius):
#First, you build the Azimuthal Equidistant Projection centered in the
# point given by WGS84 lat, lon coordinates
aeqd = pyproj.Proj(proj='aeqd', ellps='WGS84', datum='WGS84',
lat_0=lat, lon_0=lon)
#You then transform the coordinates of that point in that projection
project_coords = pyproj.transform(wgs84_globe, aeqd, lon, lat)
# Build a shapely point with that coordinates and buffer it in the aeqd projection
aeqd_buffer = Point(project_coords).buffer(radius)
# Transform back to WGS84 each coordinate of the aeqd buffer.
# Notice the clever use of sh_transform with partial functor, this is
# something that I learned here in SO. A plain iteration in the coordinates
# will do the job too.
projected_pol = sh_transform(partial(pyproj.transform, aeqd, wgs84_globe),
aeqd_buffer)
return projected_pol
La fonction point_buff_on_globe
vous donnera un polygone dans lat lon qui est le résultat de la mise en mémoire tampon le point donné dans la projection de postel centrée sur ce point (le meilleur que vous pouvez faire avec vos besoins Deux observations:...
- Je ne me souviens pas des unités de l'argument
radius
je pense est en mètres, donc si vous avez besoin d'un tampon de 10 km, vous devrez passer 10E3 Mais s'il vous plaît,
- Attention à l'utilisation de ce rayon large ou des points qui sont loin les uns des autres. Les projections fonctionnent bien lorsque les points sont proches du point où vous centrez la projection.