I'm looking for algorithm which could help me with building my own road network (for routing) from OSM data.

I chose Spatialite DB for this, but here I have only one problem: Spatialite provides interface for build road network, but prepared road graph is saved in BLOBS so I can't get any information about it (of course, I can write queries to DB for routing facilities) but I want to draw all links on my map, so I need to get their coordinates.

Actually, I'm not sure if Spatialite could provide such API or smith like that.

My question is how can I build my own road graph (network) from raw OSM data (I've already parsed XML file for highways=*) ?

  • You would find it beneficial to use postGIS and postgres with pgrouting. example anitagraser.com/2011/02/07/a-beginners-guide-to-pgrouting
    – Mapperz
    Nov 19, 2013 at 21:03
  • @Mapperz yes, but using Postgres assumes working with "not-lite" SQL DB. In my opinion sqlite is better as it doesn't need server for working. Nov 19, 2013 at 21:08
  • Postgis does not need a server - it can run locally on a pc without issue. It can even be portable gis.stackexchange.com/questions/41060/…
    – Mapperz
    Nov 19, 2013 at 21:23
  • Extracting the coordinates shouldn't be a problem - you already have them (after all, you put them into the database at the start). What is the particular issue - writing the query, the wrong format, or something else?
    – BradHards
    Nov 19, 2013 at 21:33
  • @BradHard Actually I don't understand how to define junctions(links) throw all this data. My first idea was that all ways could be used as the arcs of graph. But I'm not sure if they doesn't consist links inside them. I mean that in <way> first and last nodes always links and only they, whereas other nodes mentioned in this <way> is used only for geometry of they way. Nov 20, 2013 at 4:53

1 Answer 1


You can use our free converter for changing OSM into a routable network, that splits at all intersections. This means OSM ways are changed into multiple links. Input is OSM XML files, output is for instance SHP. Find it at www.routeware.dk, download section.

  • Thanks a lot. May be it will suit me) But anyway how did you recognize all junctions/links ? Nov 20, 2013 at 11:10
  • Basically you keep track of how many times a node is shared between ways. If more than one time, then the node is candidate for a split. Requires reading all ways twice. Nov 20, 2013 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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