NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Trying to convert the OpenStreetMap database to a weighted graph in order to apply algorithms like Dijkstra or A*. Any ideas on how to make the algorithm working on the data? The thing is to convert all the database in one time and then apply the algorithm. Right now I'm thinking of just read the database and extract the information needed to construct the graph. Make the roads as edges. As for the nodes, it's hard to determine what kind of location to keep. Need help :)

asked 04 Mar '22, 13:30

wothell's gravatar image

accept rate: 0%

Don't reinvent the wheel. Use existing software like Graphhopper, OSRM, Valhalla if you want fast and powerful routing. If you are desperate to build your own (or need to because of educational project assignment etc.), at least look at Graphhopper or OSRM source code to understand how OSM data is converted into a graph. If you really really want to build your own from scratch, look at

permanent link

answered 04 Mar '22, 13:41

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

osm4routing2 is a simple and useful tool that will take an OpenStreetMap .pbf file and convert it into a routable graph, which you can then build your routing algorithms on.

permanent link

answered 04 Mar '22, 13:45

Richard's gravatar image

Richard ♦
accept rate: 18%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 04 Mar '22, 13:30

question was seen: 1,870 times

last updated: 04 Mar '22, 13:45

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum