匀称的线串总长度

问题描述

我刚刚制作了一个带有多个 GPS 坐标点的匀称线串,我想要以米为单位的总长度。

坐标示例:[ -0.113623333333333,44.911787333333336 ]

我怎样才能做到这一点?

解决方法

您可以使用 pyproj 来测量测地线长度。

>>> from pyproj import Geod
>>> from shapely.geometry import Point,LineString
>>> line_string = LineString([Point(1,2),Point(3,4)]))
>>> geod = Geod(ellps="WGS84")
>>> total_length = geod.geometry_length(line_string)
>>> f"{total_length:.3f}"
'313588.397'

在文档中查看更多信息:https://pyproj4.github.io/pyproj/stable/examples.html#geodesic-line-length