Using R, PostGIS and pgRouting to generate network buffers

by Marcus
~1 minute read

I've written an R script that can be used in conjunction with a PostgreSQL spatially-enabled database to automatically generate drive distance or drive time based buffers for a given set of starting nodes, using the pgRouting functions: pgr_drivingDistance and pgr_pointsAsPolygon.

The polygons are written to a PostgreSQL table. It requires suitably prepared database tables derived from the Ordnance Survey Open Roads dataset, but could be modified to use any other suitably prepared routable network.

The script assumes the following:

  • You have a spatially enabled PostgreSQL database called 'spatial' which has the postgis and pgrouting extensions installed
  • You have a table called 'roadlink' in a schema called 'openroads' which has been prepared following these guidelines.

Further information, and the R script can be found in my GitHub repository.

Here's an example using the script to generate 10km drive distance network buffers for Axminster, Honiton, Feniton and Whimple railway stations:

10km drive distance network buffers