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

Clipping geometries to deploy data

A common GIS use case is clipping a big dataset into small portions (subsets), with maybe each representing an area of interest. In this recipe, you will export from a PostGIS layer representing the rivers in the world one distinct shapefile composed of rivers for each world's country. For this purpose, you will use the ST_Intersection function.

Getting ready

Be sure that you have imported in PostGIS the same river dataset (a shapefile) that was used in the previous recipe.

How to do it...

The steps you need to perform to complete this recipe are as follows:

  1. First, you will create a view to clip the river geometries for each country using the ST_Intersection and ST_Intersects functions. Name the view rivers_clipped_by_country ...

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