如何找到GPS轨迹数据集中两个相邻点之间的距离(以ft为单位)?

时间:2019-06-02 11:41:52

标签: python distance

我需要从US 101数据集中找到两条gps轨迹之间的距离,该距离总共覆盖了2000ft的距离。

"Vehicle ID","Frame ID","Total Frames","Global Time","Local X","Local Y","Global X","Global Y","V_Len","V_Width","V_Class","V_Vel","V_Acc","Lane_ID","Pre_Veh","Fol_Veh","Spacing","Headway"

2,13,437,1118846980200,16.467,35.381,6451137.641,1873344.962,14.5,4.9,2,40.00,0.00,2,0,0,0.00,0.00
2,14,437,1118846980300,16.447,39.381,6451140.329,1873342.000,14.5,4.9,2,40.00,0.00,2,0,0,0.00,0.00
2,15,437,1118846980400,16.426,43.381,6451143.018,1873339.038,14.5,4.9,2,40.00,0.00,2,0,0,0.00,0.00
2,16,437,1118846980500,16.405,47.380,6451145.706,1873336.077,14.5,4.9,2,40.00,0.00,2,0,0,0.00,0.00
2,17,437,1118846980600,16.385,51.381,6451148.395,1873333.115,14.5,4.9,2,40.00,0.00,2,0,0,0.00,0.00

但是当我试图找到同一辆车的两个相邻点之间的距离时,它的距离超过了20公里。

import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 3959 * 5280 # km
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1)
a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \
    * math.cos(math.radians(lat2)) * math.sin(dlon/2) * math.sin(dlon/2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
d = radius * c
return d
lat1 = 16.467; lat2 = 16.447; long1 = 35.381; long2 = 39.381;
print( distance((lat1, long1), (lat2, long2)) )

能帮我找出两条相邻轨迹之间的距离吗? 我需要将数据集分成多个小节,每个小节分别覆盖200英尺的距离。

1 个答案:

答案 0 :(得分:0)

您确定这些坐标是经度和纬度吗?

我对您使用的数据集不熟悉。但是,如果我没记错的话,就是this。并且文档中明确指出了有关Local X(斜体字)的信息:

  

相对于路段最左边沿行驶方向英尺的车辆前部中心的横向(X)坐标。

(与Local Y类似)。