# How convert a street map(.osm or .shp) into a weighted graph with major street squares as node and length of the street between these nodes as weight?

 0 To apply algorithms like Dijkstra on a graph, we need nodes and the distance between each node as weights. In real world these weighted graphs are actual maps and the weights are distance of road. We are looking for a library or a tool which we can be used to convert these map files(.shp or .osm) into a weighted graph or an adjacency matix? asked 13 Jan '21, 06:27 Kartikeya 11●1●1●2 accept rate: 0%

 2 There are a number of tools which will populate the pgrouting schema in PostGIS from OSM data too: osm2pgrouting and osm2po (latter is closed source proprietary software). You can readily interrogate the pgrouting tables with SQL queries and use different algorithms & weights for routing, so although not the most efficient routing method it's quite a good set-up for experimentation. Anita Graser has written a number of tutorials about pgrouting itself. answered 13 Jan '21, 13:13 SK53 ♦ 28.0k●48●268●432 accept rate: 22% Thanks for the help. We just wanted to find the shortest path by a* or dijkstra, but not by any API. We have an osm file and want to extract nodes, edges and the distance between nodes from the same file(python preferably). (03 Feb '21, 16:02) Kartikeya
 1 https://github.com/Tristramg/osm4routing2 is the easiest I've found to create a routing graph from OSM data. answered 13 Jan '21, 12:39 Richard ♦ 30.8k●44●277●411 accept rate: 18%
 toggle preview community wiki:

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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: 13 Jan '21, 06:27

question was seen: 2,727 times

last updated: 03 Feb '21, 16:02