更新时间:2022-06-25 10:41:10
Shapely仅使用笛卡尔坐标系,因此为了了解公制距离,您需要:
Shapely only uses the Cartesian coordinate system, so in order to make sense of metric distances, you would need to either:
这是使用 shapely.ops.transform href ="http://toblerity.org/shapely/manual.html#shapely.ops.transform"的方法. a>和 pyproj
import pyproj
from shapely.geometry import Point
from shapely.ops import transform
from functools import partial
WGS84 = pyproj.Proj(init='epsg:4326')
def latlonbuffer(lat, lon, radius_m):
proj4str = '+proj=aeqd +lat_0=%s +lon_0=%s +x_0=0 +y_0=0' % (lat, lon)
AEQD = pyproj.Proj(proj4str)
project = partial(pyproj.transform, AEQD, WGS84)
return transform(project, Point(0, 0).buffer(radius_m))
A = latlonbuffer(48.180759, 11.518950, 19.0)
B = latlonbuffer(47.180759, 10.518950, 10.0)
print(A.intersects(B)) # False
您的两个缓冲点不相交.但是这些确实可以做到:
Your two buffered points don't intersect. But these do:
A = latlonbuffer(48.180759, 11.518950, 100000.0)
B = latlonbuffer(47.180759, 10.518950, 100000.0)
print(A.intersects(B)) # True
如绘制lon/lat坐标(扭曲圆)所示:
As shown by plotting the lon/lat coords (which distorts the circles):