Working with OSM Data - pgRouting/pgrouting GitHub Wiki

Help I have loaded OSM (OpenStreetMap) data and pgRouting is not working!

This is a common complaint and it has to do with the fact that depending on how the data was loaded it is not properly noded for use with pgRouting. pgRotuing has some tools to help you deal with this data. Here are some links to our documentation that you need to read:

The Topology functions in the last link above are the tools that you need to run on your ways table. In general, if you load data that is well noded, then you only need to run pgr_createtopology, but with OSM data you should assume that it is not noded and run the following on it:

  1. pgr_createVerticesTable - create a table needed for analysis of the data.
  2. pgr_analyzegraph - will analyze and report potential issues.
  3. pgr_nodenetwork - this will intersect and split all crossing segments to create a properly noded 2D planar graph. You will need to join the resultant table back with the original table to reconnect it to the original segment attributes, and make appropriate adjustments to costs based on how the edges have been subdivided.