数据来源:Taxi Trajectory Data_数据集-阿里云天池 (aliyun.com)
import pandas as pd
tra=pd.read_csv('C:/Users/16000/Downloads/train/train(1).csv')
tra
170万条轨迹
TRIP_ID | 每次行程的唯一标识符 |
CALL_TYPE | 标识要求此服务的方式。可能包含三个可能的值之一:
|
ORIGIN_CALL | 包含用于要求至少一项服务的每个电话号码的唯一标识符 如果CALL_TYPE='A',它标识行程的客户。否则,它假定为NULL值 |
ORIGIN_STAND | 包含出租车站点的唯一标识符。 如果CALL_TYPE='B',它标识行程的起始点。否则,它假定为NULL值; |
TAXI_ID | 包含执行每次行程的出租车司机的唯一标识符; |
TIMESTAMP | Unix时间戳(以秒为单位) 标识行程的开始 |
DAYTYPE | 标识行程开始的天类型。它假定三个可能的值之一:
|
MISSING_DATA | 当GPS数据流完整时为FALSE 当一个(或多个)位置缺失时为TRUE; |
POLYLINE | 以字符串形式映射的GPS坐标列表(即WGS84格式) 此列表包含行程每15秒的一对坐标。 最后一个列表项对应行程的目的地,而第一个代表其开始 |
行程的总行驶时间定义为(点的数量-1)x 15秒。
例如,POLYLINE中有101个数据点的行程长度为(101-1)* 15 = 1500秒
loc=tra.at[0,'POLYLINE']
loc
'''
'[[-8.618643,41.141412],[-8.618499,41.141376],[-8.620326,41.14251],[-8.622153,41.143815],[-8.623953,41.144373],[-8.62668,41.144778],[-8.627373,41.144697],[-8.630226,41.14521],[-8.632746,41.14692],[-8.631738,41.148225],[-8.629938,41.150385],[-8.62911,41.151213],[-8.629128,41.15124],[-8.628786,41.152203],[-8.628687,41.152374],[-8.628759,41.152518],[-8.630838,41.15268],[-8.632323,41.153022],[-8.631144,41.154489],[-8.630829,41.154507],[-8.630829,41.154516],[-8.630829,41.154498],[-8.630838,41.154489]]'
'''
#提取第一条轨迹的geometry
loc_lst=json.loads(loc)
loc_lst = [[lat, lon] for lon, lat in loc_lst]
loc_lst
'''
[[41.141412, -8.618643],
[41.141376, -8.618499],
[41.14251, -8.620326],
[41.143815, -8.622153],
[41.144373, -8.623953],
[41.144778, -8.62668],
[41.144697, -8.627373],
[41.14521, -8.630226],
[41.14692, -8.632746],
[41.148225, -8.631738],
[41.150385, -8.629938],
[41.151213, -8.62911],
[41.15124, -8.629128],
[41.152203, -8.628786],
[41.152374, -8.628687],
[41.152518, -8.628759],
[41.15268, -8.630838],
[41.153022, -8.632323],
[41.154489, -8.631144],
[41.154507, -8.630829],
[41.154516, -8.630829],
[41.154498, -8.630829],
[41.154489, -8.630838]]
'''
import numpy as np
loc_lst=np.array(loc_lst)
lat,lon=np.mean(loc_lst,axis=0)
lat,lon
#(41.14919347826088, -8.62801630434783)
import folium
m=folium.Map(location=(lat,lon),
zoom_start=15)
folium.PolyLine(locations=loc_lst,
weight=10).add_to(m)
m
#画图