简体   繁体   English

OSM到直接图(python-igraph / networkx)

[英]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: 我正在使用此python脚本下载OSM数据并将其转换为无向的networkx图形:

https://gist.github.com/rajanski/ccf65d4f5106c2cdc70e 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. 但是,在理想情况下,我想从中生成一个有向图,以反映osm街道网络的方向性。

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? 首先,您是否可以确认在OSM原始xml数据中此处此处所述,nd项的顺序对方向很重要?

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? 其次,您如何建议从osm原始数据生成有向图,并将上述要点代码片段作为模板提供?

many thanks! 非常感谢!

The order of the nodes only matters if the way is tagged with oneway =yes or oneway=-1 . 节点的顺序仅在将方式标记为oneway = yesoneway = -1时才重要。 Otherwise the way is bidirectional. 否则,方法是双向的。 This applies only for vehicles of course. 当然,这仅适用于车辆。 The only exception is highway=motorway which implies oneway=yes . 唯一的例外是Highway = motorway ,这意味着oneway = yes

You might also be interested in the routing wiki page. 您可能也对路由 Wiki页面感兴趣。 It lists two routers implemented in python, and many others. 它列出了两个用python实现的路由器,还有许多其他路由器。

OK, I updated my script in order to enable directionality: 好的,我更新了我的脚本以启用方向性:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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