Database Reference
In-Depth Information
GIS analysis with spatial joins
JoinsforregularSQLtableshavetherealpowerinarelationaldatabaseandspatial
joins are one of the most impressive features of a spatial database engine such as
PostGIS.
Basically,itispossibletocorrelateinformationfromdifferentlayersonthebasisofthe
geometricrelationofeachfeaturefromtheinputlayers.Inthisrecipe,wewilltakea
tour of some common use cases of spatial joins.
Getting ready
1. First, import some data to be used as a test bed in PostGIS. Download the
.kmz filecontainingtheinformation about2012globalearthquakesfromthe
USGS website at http://earthquake.usgs.gov/earthquakes/eqarchives/epic/
kml/2012_Earthquakes_ALL.kmz . Save it in the working/chp03 directory
(alternatively, you can use the copy of this file included in the code bundle
provided with this topic).
2. A .kmz file is a collection of .kml files packaged with the ZIP compressor.
Therefore,afterunzippingthefile(youmayneedtochangethe .kmz fileex-
tension to .zip ), you may notice that it is composed of just a single .kml
file.Thisfile,whichisintheGDALabstraction,constitutesanOGRKMLdata
sourcecomposedofninedifferentlayersandcontaining3Dpointgeometries.
Each layer contains earthquake data for each distinct earthquake magnitude:
$ ogrinfo 2012_Earthquakes_ALL.kml
Had to open data source read-only.
INFO: Open of `2012_Earthquakes_ALL.kml'
using driver `KML' successful.
1: Magnitude 8 (3D Point)
2: Magnitude 7 (3D Point)
...
8: Magnitude 1 (3D Point)
9: Magnitude None (3D Point)
Search WWH ::




Custom Search