简体   繁体   中英

OSM to DIRECTED Graph (python-igraph / networkx)

I am using this python script to download OSM data and convert it to an undirected networkx graph:

https://gist.github.com/rajanski/ccf65d4f5106c2cdc70e

However,in the ideal case, I would like to generate a directed graph from it in order to refelct the directionality of the osm street network.

First of all, can you confirm that as stated here and here in OSM raw xml data, the order of the nd-entries in the way is what matters for the direction?

And secondly, how would you suggest to implement the generation of a directed graph from the osm raw data, give the the above gist code snippet as a template?

many thanks!

The order of the nodes only matters if the way is tagged with oneway =yes or oneway=-1 . Otherwise the way is bidirectional. This applies only for vehicles of course. The only exception is highway=motorway which implies oneway=yes .

You might also be interested in the routing wiki page. It lists two routers implemented in python, and many others.

OK, I updated my script in order to enable directionality:

https://gist.github.com/rajanski/ccf65d4f5106c2cdc70e

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