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
For this recipe, we will use the Rivers + lake centerlines dataset of North America and Europe with a scale 1:10m. Download therivers
dataset fromthefollowingnaturalearthdata.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/ne_10m_rivers_lake_centerlines.zip
Or find it on the following website:
http://www.naturalearthdata.com/downloads/10m-physical-vectors/
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 > rivers.sql$ psql -U me -d...