【发布时间】:2020-05-22 13:15:07
【问题描述】:
我正在尝试在 Shapely 中查找线串的长度(以米为单位),但似乎无法达到预期的结果。几乎可以肯定我在坐标系方面犯了一些错误,但我无法弄清楚。
下面是单行的一些简化代码:
from shapely.geometry import LineString
line = LineString([(12875996.563923, -3940011.116702), (12872802.929335, -3937989.118438)])
line.crs = 'EPSG:3857'
line.length
输出为 3779.92m。但是,根据我的测量,它应该是 ~3159m。
这是基于检查以下站点的点(两个环形交叉路口的中心)的位置,然后在 Google 地球中测量它们之间的位置。
第 1 点:
http://epsg.io/map#srs=3857&x=12875996.563923&y=-3940011.116702&z=14&layer=streets
第 2 点:
http://epsg.io/map#srs=3857&x=12872802.929468&y=-3937989.118538&z=17&layer=streets
【问题讨论】:
-
EPSG:3857 是球形墨卡托投影坐标系。在大多数情况下,长度失真是不可接受的。
-
Shapely doesn't support 坐标系转换。分配
crs属性没有任何效果。评论那行,你会看到结果是一样的。我认为您需要改用 pyproj 库。检查this example in Shapely docs 和this entry in pyproj docs。
标签: python spatial coordinate-systems shapely