Book Image

PostGIS Cookbook - Second Edition

By : Pedro Wightman, Bborie Park, Stephen Vincent Mather, Thomas Kraft, Mayra Zurbarán
Book Image

PostGIS Cookbook - Second Edition

By: Pedro Wightman, Bborie Park, Stephen Vincent Mather, Thomas Kraft, Mayra Zurbarán

Overview of this book

PostGIS is a spatial database that integrates the advanced storage and analysis of vector and raster data, and is remarkably flexible and powerful. PostGIS provides support for geographic objects to the PostgreSQL object-relational database and is currently the most popular open source spatial databases. If you want to explore the complete range of PostGIS techniques and expose related extensions, then this book is for you. This book is a comprehensive guide to PostGIS tools and concepts which are required to manage, manipulate, and analyze spatial data in PostGIS. It covers key spatial data manipulation tasks, explaining not only how each task is performed, but also why. It provides practical guidance allowing you to safely take advantage of the advanced technology in PostGIS in order to simplify your spatial database administration tasks. Furthermore, you will learn to take advantage of basic and advanced vector, raster, and routing approaches along with the concepts of data maintenance, optimization, and performance, and will help you to integrate these into a large ecosystem of desktop and web tools. By the end, you will be armed with all the tools and instructions you need to both manage the spatial database system and make better decisions as your project's requirements evolve.
Table of Contents (18 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

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

  1. First, import some data to be used as a test bed in PostGIS. Download the .kmz file 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 the working/chp03 directory (alternatively, you can use the copy of this file included in the code bundle provided with this book).
  2. A .kmz file is a collection of .kml files packaged with the ZIP compressor. Therefore, after unzipping the file (you may need to change the .kmz file extension to...