简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM