Shortest Path (Dijkstra’s) Algorithm: A Step-by-Step Python Guide | by Bryan R. Vallejo | Oct, 2023

This well-known algorithm is implemented in the Python library OSMNX and can be used to find the shortest path weighted by distance or time between two locations. The algorithm uses the OpenStreetMap (OSM) network to either drive, walk, or bike, to find the route using the Python library NETWORKX in the background.

I am writing this update because the parameters of the functions have changed a little bit and I have been asked why my code is not working in old blog posts, and it is simply because the code was written with older versions of osmnx.

The old tutorial contains quite valuable processes, but I also decided to do a step-by-step guide so the process of getting the shortest path is more precise and the analyst that uses this guide can really get the idea of the process.

Here are the old tutorials if you want to give it a look.

In Helsinki (Finland), using a different networks

In Tartu (Estonia), using a walking network

In this practice, I am going to use two locations from Morocco. The practice was suggested by one of my readers Hanae who provided the origin and destination.

Source link

Be the first to comment

Leave a Reply

Your email address will not be published.