【发布时间】:2019-11-29 13:55:52
【问题描述】:
所以我有这个坐标列表,我需要它们之间距离的最终总和。
track = [[49.16967, 20.21491, 1343],
[49.17066, 20.22002, 1373],
[49.16979, 20.22416, 1408],
[49.17077, 20.22186, 1422],
[49.17258, 20.22094, 1467],
[49.17294, 20.21944, 1460]]
到目前为止,我已经有了计算两组坐标之间距离的基本公式
import math
def distance(lat_start, lon_start, lat_ciel, lon_ciel):
R = 6371000
lat_start = math.radians(lat_start)
lon_start = math.radians(lon_start)
lat_ciel = math.radians(lat_ciel)
lon_ciel = math.radians(lon_ciel)
DiffLat = lat_ciel - lat_start
DiffLon = lon_ciel - lon_start
a = math.sin(DiffLat/2) ** 2 + math.cos(lat_start) * math.cos(lat_ciel) * math.sin(DiffLon / 2) ** 2
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
return R * c
我被困在下一步,我尝试创建一个不同的函数,它使用现有函数作为距离,只需获取每组坐标并计算距离,然后将结果数字相加。
感谢您的帮助。
【问题讨论】:
-
显示你到目前为止的代码并解释它的问题。
-
您的问题是生成所有点对以及如何求和点对之间的距离?
标签: python list gps coordinates