Search code examples
pythonosmnxvehicle-routing

finding way ids for list of osm nodes in shortest path


In a route, we get a list of all the nodes from the source to destination.

route = nx.shortest_path(G,origin_node,desitination_node, weight='length')

Is it possible to get all the osm way ids from source to destination?


Solution

  • Yes, the route is a list of nodes. Iterate through this list pairwise to get edge (u, v) tuples (for instance see https://stackoverflow.com/a/4628446/7321942). Look up those edge tuples in the graph to get the constituent OSM way IDs corresponding to those edges.