将点捕捉到自定义道路网络上

2024-09-30 20:34:09 发布

您现在位置:Python中文网/ 问答频道 /正文

这不是一个重复的问题,因为我有一些具体的要求。请提供输入wrt python。 我有一个节点坐标形式的道路网,也就是说,我有一个城市所有路线的横向和纵向

现在,我有一个GPS坐标(公交线路)列表,我想将其与原始路线匹配

这类似于谷歌道路API。我试过使用反向地理编码器,但我能理解。请帮助


Tags: api列表节点编码器路线地理形式gps
1条回答
网友
1楼 · 发布于 2024-09-30 20:34:09

您可以使用python的osmnx包。您可以创建纬度和经度坐标的边界框,检索此框的相应地图数据,然后将横向坐标捕捉到街道网络的最近节点

bounding_box = ((gps_df.longitude.min(), gps_df.longitude.max(),
                 gps_df.latitude.min(), gps_df.latitude.max()))

# Downloading the map as a graph object
g = ox.graph_from_bbox(north, south, east, west, network_type='drive')

route = []

# get the nearest nodes to the locations
for i in range(len(lat_list)):
    node = ox.get_nearest_node(g, (lat_list[i], long_list[i]))
    route.append(node)

#flat the lists
edge_nodes = list(zip(route[:-1], route[1:]))

相关问题 更多 >