在地球投影上相交两个匀称的多边形

时间:2017-06-16 07:46:04

标签: python geospatial shapely geos pyproj

据我所知,只使用笛卡尔坐标系。我有两个点在地球上有lat和lon坐标。我需要在这两个点周围创建1km半径的缓冲区,并找到多边形,这个缓冲区相交。

但是建设

buffer = Point(54.4353,65.87343).buffer(0.001)创建简单的圆,但在地球投影中它变成椭圆,但我需要两个半径为1 km的实圆。

我认为,我需要将我的缓冲区转换为新的投影,然后将其交叉,但现在不正确。

1 个答案:

答案 0 :(得分:2)

你需要做你说的话。为此,您需要使用处理投影的库(pyproj是此处的选择)。 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

函数point_buff_on_globe将为你提供一个lat lon的多边形,这是缓冲以该点为中心的方位角等距投影中的给定点的结果(你可以根据自己的要求做到最好。两个观察结果:< / p>

  1. 我不记得radius参数的单位。我认为是米,所以如果你需要一个10公里的缓冲区,你需要传递它10e3。但请检查一下!
  2. 小心使用半径到宽度或远离彼此的点。当点接近投影中心点时,投影效果很好。
相关问题