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
你要照你说的做。为此,您需要使用一个处理投影的库(
pyproj
是这里的选择)。在Geodesic buffering in python中有一个类似的问题函数
point_buff_on_globe
将给你一个纬度上的多边形,这是在以该点为中心的方位角等距投影中缓冲给定点的结果(您可以根据您的要求做的最好)。两个观察结果:radius
参数的单位。我想是以米为单位的,所以如果你需要一个10公里的缓冲区,你需要通过它10e3。但是请检查一下!在相关问题 更多 >
编程相关推荐