首页 > 解决方案 > 在 Python OSMNX 上的给定地图上绘制路线

问题描述

我有一个数据框,其中包含来自车辆的 GPS 数据。它有经度、纬度值和时间戳。我想在地图上可视化汽车的路线。

OSMNX 有一个函数“plot_graph_route”和“plot_graph_folium”,它将路线作为参数,但我不知道我应该给出什么样的结构。

标签: pythongraphroutingnetworkxosmnx

解决方案


我不知道我应该给出什么样的结构

OSMnx 文档plot_graph_route中完整描述了其参数的用法和结构。OSMnx 示例中记录了在 lat-lng 点之间绘制路线的技术,如下所示:

origin_point = (37.792896, -122.412325)
destination_point = (37.790495, -122.408353)
origin_node = ox.get_nearest_node(G, origin_point)
destination_node = ox.get_nearest_node(G, destination_point)
route = nx.shortest_path(G, origin_node, destination_node, weight='length')
fig, ax = ox.plot_graph_route(G, route, origin_point=origin_point, destination_point=destination_point)

文档和示例都类似地描述了该plot_graph_folium功能。


推荐阅读