PostGIS Cookbook
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
$25.49
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
$49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • Integrate PostGIS with web frameworks and implement OGC standards such as WMS and WFS using MapServer and GeoServer
  • Convert 2D and 3D vector data, raster data, and routing data into usable forms
  • Visualize data from the PostGIS database using a desktop GIS program such as QGIS and OpenJUMP
  • Easy-to-use recipes with advanced analyses of spatial data and practical applications

Book Details

Language : English
Paperback : 484 pages [ 235mm x 191mm ]
Release Date : January 2014
ISBN : 1849518661
ISBN 13 : 9781849518666
Author(s) : Paolo Corti, Stephen Vincent Mather, Thomas J Kraft, Bborie Park
Topics and Technologies : All Books, Cookbooks, Open Source


Table of Contents

Preface
Chapter 1: Moving Data In and Out of PostGIS
Chapter 2: Structures that Work
Chapter 3: Working with Vector Data – The Basics
Chapter 4: Working with Vector Data – Advanced Recipes
Chapter 5: Working with Raster Data
Chapter 6: Working with pgRouting
Chapter 7: Into the Nth Dimension
Chapter 8: PostGIS Programming
Chapter 9: PostGIS and the Web
Chapter 10: Maintenance, Optimization, and Performance Tuning
Chapter 11: Using Desktop Clients
Index
  • Chapter 1: Moving Data In and Out of PostGIS
    • Introduction
    • Importing nonspatial tabular data (CSV) using PostGIS functions
    • Importing nonspatial tabular data (CSV) using GDAL
    • Importing shapefiles with shp2pgsql
    • Importing and exporting data with the ogr2ogr GDAL command
    • Handling batch importing and exporting of datasets
    • Exporting data to the shapefile with the pgsql2shp PostGIS command
    • Importing OpenStreetMap data with the osm2pgsql command
    • Importing raster data with the raster2pgsql PostGIS command
    • Importing multiple rasters at a time
    • Exporting rasters with the gdal_translate and gdalwarp GDAL commands
  • Chapter 2: Structures that Work
    • Introduction
    • Using geospatial views
    • Using triggers to populate a geometry column
    • Structuring spatial data with table inheritance
    • Extending inheritance – table partitioning
    • Normalizing imports
    • Normalizing internal overlays
    • Using polygon overlays for proportional census estimates
  • Chapter 3: Working with Vector Data – The Basics
    • Introduction
    • Working with GPS data
    • Fixing invalid geometries
    • GIS analysis with spatial joins
    • Simplifying geometries
    • Measuring distances
    • Merging polygons using a common attribute
    • Computing intersections
    • Clipping geometries to deploy data
    • Simplifying geometries with PostGIS topology
  • Chapter 4: Working with Vector Data – Advanced Recipes
    • Introduction
    • Improving proximity filtering with KNN
    • Improving proximity filtering with KNN – advanced
    • Rotating geometries
    • Improving ST_Polygonize
    • Translating, scaling, and rotating geometries – advanced
    • Generating detailed building footprints from LiDAR
    • Using external scripts to embed new
    • functionality in order to calculate a Voronoi diagram
    • Using external scripts to embed other
    • libraries in order to calculate a Voronoi
    • diagram – advanced
  • Chapter 5: Working with Raster Data
    • Introduction
    • Getting and loading rasters
    • Working with basic raster information and analysis
    • Performing simple map-algebra operations
    • Combining geometries with rasters for analysis
    • Converting between rasters and geometries
    • Processing and loading rasters with GDAL VRT
    • Warping and resampling rasters
    • Performing advanced map-algebra operations
    • Executing DEM operations
    • Sharing and visualizing rasters through SQL
  • Chapter 6: Working with pgRouting
    • Introduction
    • Startup – Dijkstra routing
    • Loading data from OpenStreetMap and finding the shortest path using A*
    • Driving distance/service area calculation
    • Calculating demographics using driving distance
    • Extracting the centerlines of polygons
  • Chapter 7: Into the Nth Dimension
    • Introduction
    • Importing LiDAR data
    • Performing 3D queries on a LiDAR point cloud
    • Constructing and serving buildings 2.5 D
    • Using ST_Extrude to extrude building footprints
    • Creating arbitrary 3D objects for PostGIS
    • Exporting models as X3D for the Web
    • Reconstructing Unmanned Aerial Vehicle (UAV) image footprints with PostGIS 3D
    • UAV photogrammetry in PostGIS – point cloud
    • UAV photogrammetry in PostGIS – orthorectification
    • UAV photogrammetry in PostGIS – DSM creation
  • Chapter 8: PostGIS Programming
    • Introduction
    • Writing PostGIS vector data with Psycopg
    • Writing PostGIS vector data with OGR Python bindings
    • Writing PostGIS functions with PL/Python
    • Geocoding and reverse-geocoding using the GeoNames datasets
    • Geocoding using the OSM datasets with trigrams
    • Geocoding with geopy and PL/Python
    • Importing netCDF datasets with Python and GDAL
  • Chapter 9: PostGIS and the Web
    • Introduction
    • Creating WMS and WFS services with MapServer
    • Creating WMS and WFS services with GeoServer
    • Creating a WMS Time with MapServer
    • Consuming WMS services with OpenLayers
    • Consuming WMS services with Leaflet
    • Consuming WFS-T services with OpenLayers
    • Developing web applications with GeoDjango – part 1
    • Developing web applications with GeoDjango – part 2
  • Chapter 10: Maintenance, Optimization, and Performance Tuning
    • Introduction
    • Organizing the database
    • Setting up the correct data privilege mechanism
    • Backing up the database
    • Using indexes
    • Clustering for efficiency
    • Optimizing SQL queries
    • Migrating a PostGIS database to a different server
    • Replicating a PostGIS database with streaming replication
  • Chapter 11: Using Desktop Clients
    • Introduction
    • Adding PostGIS layers – QGIS
    • Using the Database Manager plugin – QGIS
    • Adding PostGIS layers – OpenJUMP GIS
    • Running database queries – OpenJUMP GIS
    • Adding PostGIS layers – gvSIG
    • Adding PostGIS layers – uDig

Paolo Corti

Paolo Corti is based in Rome, Italy. He is an environmental engineer with more than 15 years of experience in the GIS sector. After working with proprietary solutions for some years, he has proudly switched to open-source technologies and Python for almost a decade. He has been working as a developer and analyst for organizations such as the EU Joint Research Center, UN World Food Program, and the Italian Government. Currently, he is working within the GeoNode project, for which he is a core developer, in the context of emergency preparedness and response. He is an OSGeo Charter member and writes a blog on open-source GIS at http://www.paolocorti.net/. He is the author of the book's chapters 1, 3, 8, and 9.

Stephen Vincent Mather

Stephen Vincent Mather has worked in the geospatial industry for 15 years, having always had a flair for geospatial analyses in general, especially those at the intersection of Geography and Ecology. His work in open-source geospatial databases started 5 years ago with PostGIS and he immediately began using PostGIS as an analytic tool, attempting a range of innovative and sometimes bleeding-edge techniques (although he admittedly prefers the cutting edge). His geospatial career has spanned a variety of interesting and novel natural-resource projects, everything from the movement of ice sheets in Antarctica to hiking viewsheds and mobile trail applications to help park users find trails, picnic areas, and restrooms. Stephen is currently the GIS manager for Cleveland Metroparks in Cleveland, Ohio. He manages a small geospatial shop that specializes in high-end cartography, crating and generating data, geospatial web development, and analyses for natural-resource management, largely with open-source software. Stephen is also a Mennonite technologist, aka a straw-hat hacker, interested in creating fair and open data and infrastructure for better governance and humanitarian purposes. He is heavily involved in the Cleveland Civic Hacking movement as he works with the public to help them get engaged with geospatial data. In his spare time, he builds guitars really, really slowly.

Thomas J Kraft

Thomas J Kraft is currently a Planning Technician at Cleveland Metroparks after beginning as a GIS intern in 2011. He graduated with Honors from Cleveland State University in 2012, majoring in Environmental Science with an emphasis on GIS. When not in front of a computer, he enjoys his weekends landscaping and the outdoors in general.

Bborie Park

Bborie Park has been breaking (and subsequently fixing) computers for most of his life. His primary interests involve developing end-to-end pipelines for spatial datasets. He is an active contributor to the PostGIS project and is a member of the PostGIS Steering Committee. He happily resides with his wife Nicole in the San Francisco Bay Area.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 7 submitted: last submission 28 Jul 2014

Errata type: Technical | Page no.: 371

The URL is:

http://www.packtpub.com/postgis-cookbook/book

It should be:

http://www.packtpub.com/postgis-to-store-organize-manipulate-analyze-spatial-data-cookbook/book

Errata type: Technical | Page no.: 22

In the fourth point of the How to do it section, use LIMIT 50 in the query, or change the active hotspots number in the text from 50 to 100.

 

 

 

Errata type: Code | Page no.: 33

The code in the third point of the How to do it section is:

postgis_cookbook=> SELECT MIN(subregion) AS subregion,

    ST_Union(the_geom) AS the_geom, SUM(pop2005) AS pop2005

    FROM chp01.countries GROUP BY subregion;

It should be:

postgis_cookbook=> SELECT subregion,

    ST_Union(the_geom) AS the_geom, SUM(pop2005) AS pop2005

    FROM chp01.countries GROUP BY subregion;

Errata type: Code | Page no.: 118

The code in point number 4 is:

        $ chmod 775 rivers.sh

It should be:

        $ chmod 775 export_rivers.sh

Errata type: Code | Page no.: 60

SQL is wrong due to use "geom" , changing it to "the_geom" would be success;

Errata type: Code | Page no.: 75

Last 3 lines: change "geo.geom" to "geo.the_geom"

Errata type: Code | Page no.: 176

SQL has quotation errors

Original code is:

 UPDATE chap5.prism SET month_year = (
    split_part(split_part(filename, ''.'', 1), ''_'', 3) || ''-'' ||

    split_part(filename, ''.'', 2) || ''-01'' )::date;

 

It should be:

  UPDATE chap5.prism SET month_year = (
    split_part(split_part(filename, '.', 1), '_', 3) || '-' ||

    split_part(filename, '.', 2) || '-01' )::date;

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

PostGIS Cookbook +    Practical Data Analysis =
50% Off
the second eBook
Price for both: €31.40

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Import and export geographic data from the PostGIS database using the available tools
  • Structure spatial data using the functionality provided by the combination of PostgreSQL and PostGIS
  • Work with a set of PostGIS functions to perform basic and advanced vector analyses
  • Connect PostGIS with Python
  • Learn to use programming frameworks around PostGIS
  • Maintain, optimize, and fine-tune spatial data for long-term viability
  • Explore the 3D capabilities of PostGIS, including LiDAR point clouds and point clouds derived from Structure from Motion (SfM) techniques
  • Distribute 3D models through the Web using the X3D standard
  • Use PostGIS to develop powerful GIS web applications using Open Geospatial Consortium web standards
  • Master PostGIS Raster

In Detail

PostGIS is a spatial database that integrates 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 the related extensions, this book is a must-have.

This book is a deep-dive into the full range of PostGIS topics, with practical applications of the concepts and code. It is a comprehensive guide on PostGIS tools and concepts which are required to manage, manipulate, and analyse spatial data in PostGIS. This book is packed with systematic instructions of hands-on examples and in-depth explanations. Even for experienced users, this book will serve as a great source of reference by providing new ways of working with PostGIS through the book's easy-to-follow approach.

This hands-on guide looks at 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.

This practical book will help you take advantage of basic and advanced vector, raster, and routing approaches. You will learn to use the concepts of data maintenance, optimization, and performance, which will help you to integrate these into a large ecosystem of desktop and web tools.

With this comprehensive guide, 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.

Approach

An easy-to-use guide, full of hands-on recipes for manipulating spatial data in a PostGIS database. Each topic is explained and placed in context, and for the more inquisitive, there are more details of the concepts used.

Who this book is for

If you are a web developer or a software architect, especially in location-based companies, and want to expand the range of techniques you are using with PostGIS, then this book is for you. You should have some prior experience with PostgreSQL database and spatial concepts.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software