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

Computing intersections

One typical GIS geoprocessing workflow is to compute intersections generated by intersecting linear geometries.

PostGIS offers a rich set of functions for solving this particular type of problem and you will have a look at them in this recipe.

Getting ready

Download the rivers dataset from the following naturalearthdata.com website (or use the ZIP file included in the code bundle provided with this book):

http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/10m-rivers-lake-centerlines.zip

Extract the shapefile to your working directory, chp03/working. Import the shapefile in PostGIS using shp2pgsql as follows:

$ shp2pgsql -I -W LATIN1 -s 4326 -g the_geom ne_10m_rivers_lake_centerlines.shp chp03.rivers ...

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