首页 > 解决方案 > 将一个点捕捉到自定义道路网络

问题描述

这不是一个重复的问题,因为我有一些具体要求。请提供输入 wrt python。我有一个节点坐标形式的道路网络,即我拥有城市所有路线的所有纬度和经度。

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

这类似于 Google 道路 API。我尝试使用反向地理编码器,但我能理解它..请帮助

标签: pythonpython-3.xroutinggpsreverse-geocoding

解决方案


你可以使用 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:]))

推荐阅读