GIS analysis with spatial joins
Joins for regular SQL tables have the real power in a relational database, and spatial joins are one of the most impressive features of a spatial database engine such as PostGIS.
Basically, it is possible to correlate information from different layers on the basis of the geometric relation of each feature from the input layers. In this recipe, we will take a tour of some common use cases of spatial joins.
Getting ready
- First, import some data to be used as a test bed in PostGIS. Download the
.kmzfile containing information about 2012 global earthquakes from the USGS website at http://earthquake.usgs.gov/earthquakes/eqarchives/epic/kml/2012_Earthquakes_ALL.kmz. Save it in theworking/chp03directory (alternatively, you can use the copy of this file included in the code bundle provided with this book). - A
.kmzfile is a collection of.kmlfiles packaged with the ZIP compressor. Therefore, after unzipping the file (you may need to change the.kmzfile extension to...