I need a tool to find the distance between two points whose longitude and latitude are given. I am making an application so it will require bulk queries, so i cannot use google maps distance matrix API that could tell me the distance via road, airways or any other. So I turned up to OSM data, i downloaded the OSM data and then pgrouting tool. But I am unable to find the distance via road between two points from this data stored in postgres table.

Any help regarding how to fetch this data from the postgresql db or any other resource you know that can accomplish my goal will be greatly appreciated.

  • pgRouting requires each road entry to have a start and an end node id. If your dataset already contains this information, you can skip this step. Otherwise we will create the node ids now - underdark.wordpress.com/2011/02/07/… credit to @underdark
    – Mapperz
    Jun 19, 2012 at 21:11
  • CAn you project the point to the nearest line and use the projection for mapping?
    – dassouki
    Aug 30, 2012 at 23:38

2 Answers 2


OSM has a page dedicated to routing, which is worth going over:


There is a special tool for importing OSM data into a PGRouting system and generating the required structure:


Lastly, there is a workshop tutorial on getting routing working with OSM data here:



You can use GraphHopper for this task. Have a look into the documentation for more information.

Your Answer

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

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