NOTICE: help.openstreetmap.org 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

wothell
11112
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 https://help.openstreetmap.org/questions/19213/how-can-i-convert-an-osm-xml-file-into-a-graph-representation

permanent link

answered 04 Mar '22, 13:41

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
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 ♦
30.9k44279412
accept rate: 18%

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×118
×47
×18
×6

question asked: 04 Mar '22, 13:30

question was seen: 2,518 times

last updated: 04 Mar '22, 13:45

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