Dijkstra’s algorithm weighted by travel time in OSM networks
Finding the fastest and shortest path with the OSMNX 1.6
The Shortest Path (Dijkstra’s) algorithm can be applied in OSM networks like driving, bike, and pedestrian, to find the most optime route between origin and destination. But, the algorithm calculates in the network the shortest routes based on distance and it does not really mean the most optime route. The distance in a road network can be relative when we consider the speed of the roads. Definitely, the most optime route between the two points might be the shortest if the road network has equal speed on all roads. In the case we compare the speed in highways with urban streets we will refactor this idea understanding that the most optime route is the fastest.
“The distance in a road network can be relative when we consider the speed of the roads”
Thanks to the Python library OSMNX, it is possible to add speed to different kinds of roads at the global level and calculate the Travel times between nodes in the OSM network. This allows the Python library to process the Shortest Path algorithm weighted by Travel times.
This practice is the continuation of a previous tutorial that used the Shortest Path algorithm to calculate the shortest route between two locations in Morocco.
Shortest route in OSM network in Morocco
Access coding tutorials
If you are not yet a member of
you will be required to subscribe to access the stories. You can follow more coding tutorials and support my work by joining using my personal link. Be part of this coding journey.Join here 👉 https://bit.ly/3yjLsSL
OSM data license
- Open Street Map data. Licensed under Open Data Commons Open Database License (ODbl) or attribution license…