From OpenStreetMap Wiki
Jump to navigation Jump to search


Program takes osm file and one location/node as destination and computes and displays distance to node/destination for all other junctions in map/file. Result is PNG, SVG, GPX, OSM. Valid/usable ways can be given. Distance is calculated by an Dijkstra algorithm using only ways defined as valid. So it's not the distance along the beeline!
So you can

  • find out how far it is from A to B (destination) and
  • you can see if destination is reachable at all! (If dist is infinity, there is no valid route). This is useful to check if data is routable. You can find unconnected ways! Just load the GPX output into JOSM and see where inf appears. This node is unreachable.

Picture of sample map



  • PNG and SVG file with map and displayed distance to destination. SVG also contains road names (depends on renderer!).
  • GPX file with distances for further processing
  • OSM snippet to insert into original OSM file so information can be rendered with a renderer like Maperitive


  • Install Perl Modules osm.pm and osmgraph.pm in appropriate directory
  • Edit distancemap.pl for valid ways and destination point
  • Then call distancemap
perl distancemap.pl file.osm out.png [picsize]
  • file.osm is input file
  • out.png is picture output file name (other names automatic)
  • optionally you can specify another picture size (X/lon axis in pixels). Default is 4096 pixels.


  • destination node can be given
  • valid ways can be specified

Not supported

  • oneways
  • access tags


Source code of library modules

See also

Distance maps