O'Reilly logo

PostGIS Cookbook by Bborie Park, Stephen Vincent Mather, Thomas J. Kraft, Paolo Corti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Startup – Dijkstra routing

pgRouting is a separate extension used in addition to PostGIS. Its download and installation is vastly simplified by DEB, RPM, and OS X packages and Windows binaries available at http://pgrouting.org/download.html.

Getting ready

pgRouting doesn't deal well with non-default schema, so before we begin, we will set the schema in our user preferences using the following command:

ALTER ROLE me SET search_path TO chp06,public;

Next, we need to add the pgRouting extension to our database. If PostGIS is not already installed on the database, we'll need to add that as an extension, as well:

--CREATE EXTENSION postgis;
CREATE EXTENSION pgrouting;

We will start by loading a test dataset. You can get some really basic sample data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required