Finding the Dijkstra shortest path with pgRouting

There are a few Python libraries out there, such as networkX and scikit-image, that can find the shortest path over a raster or NumPy array. We want to focus on routing over a vector source and returning a vector dataset; therefore, pgRouting is a natural choice for us. Custom Python Dijkstra or the A Star (A*) shortest path algorithms exist but one that performs well on large networks is hard to find. The pgRouting extension of PostgreSQL is used by OSM and many other projects and is well tested.

Our example will have us load a Shapefile of an indoor network from one floor for simplicity's sake. An indoor network is comprised of network lines that go along the hallways and open walkable spaces ...

Get Python Geospatial Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.