4

I wish to extract from an OSM file a road network, and export it as an array (adjacency matrix) where the nodes are the road intersections and the edges represent the road segments.

I don't want to just visualise it, but also export the resulting adjacency matrix as a file with a network data structure in at least one of the following formats: numpy file (.npy), pajek file (.net), gephi file (.gexf), csv file (.csv). Alternatively, a list of nodes and edges with geometric info would do.

I seek a solution using either Python or QGIS.

I was hoping for something like this Matlab package, especially the 3rd item in the description. Unfortunately, I don't have Matlab installed on my machine.

3 Answers 3

3

I do not know an exact solution, but will try to present you general ideas:

What you are looking for is adjacence matrix for an routing graph that is generated out of OSM geodata. While there is a huge interest in the routing topic at the community, there are just very few approaches to export the routing graph, as user usually want a full featured routing solution.

  • eWorld is a frontend for the SUMO engine that enables this simulator to make use of OSM. You can get network files etc.
  • osm2pgrouting fills a PostGIS DB according to the requirements of the pgrouting module
  • QGIS road graph plugin can also be used on OSM for example with the OSM import plugin or with preprocessed shapefiles
  • osm4routing might fit your export requirements, but I never heard of it before so I guess it's not in wide use...

A last idea would be to play with the trafficmining framework that seems to be very modular, so I guess you can get access to the processed data (but it's in JAVA)

All in all it depends on your use case.

1
  • I will look into SUMO. What I have done so far is implement Vector > Analysis Tools > Line Intersections and export the attribute table as a shapefile with both latitude and longitude information. From there, I use Python (packages pyshp and networks) to extract and build the network.
    – EFL
    Commented Jan 20, 2014 at 8:43
1

http://osm-traffic.com/ allows direct download of graph data from OpenStreetMap in json format.

Disclaimer: I work with the company who developed it, it might become a pay service.

0

A systematic method has been developed for this according to NIH "A protocol to convert spatial polyline data to network formats and applications to world urban road networks"

1
  • OP wants (pure?) Python or QGIS, and this discusses some ArcGIS tool the authors made for extracting routable networks from OSM. So only tangentially related to the question. Commented Oct 25, 2017 at 5:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.