3

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.

A solution using either Python or QGIS would be highly appreciated.

Edit: 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

I'm sorry that I don't 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)

Hope that will help a bit. All in all it depends on your usecase, good luck!

  • 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 Jan 20 '14 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.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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"

  • 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. – Richard Law Oct 25 '17 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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