PostGIS Cookbook - Second Edition

Book description

Create and manage spatial data with PostGIS

About This Book

  • Import and export geographic data from the PostGIS database using the available tools
  • Maintain, optimize, and fine-tune spatial data for long-term viability
  • Utilize the parallel support functionality that was introduced in PostgreSQL 9.6

Who This Book Is For

This book is for developers who need some quick solutions for PostGIS. Prior knowledge of PostgreSQL and spatial concepts would be an added advantage.

What You Will Learn

  • Import and export geographic data from the PostGIS database using the available tools
  • Structure spatial data using the functionality provided by a 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 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.

Style and approach

This comprehensive guide uses a problem-solving approach to help you acquire a solid understanding of PostGIS.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. PostGIS Cookbook Second Edition
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the authors
    2. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
  6. Moving Data In and Out of PostGIS
    1. Introduction
    2. Importing nonspatial tabular data (CSV) using PostGIS functions
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Importing nonspatial tabular data (CSV) using GDAL
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Importing shapefiles with shp2pgsql
      1. How to do it...
      2. How it works...
      3. There's more...
    5. Importing and exporting data with the ogr2ogr GDAL command
      1. How to do it...
      2. How it works...
      3. See also
    6. Handling batch importing and exporting of datasets
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Exporting data to a shapefile with the pgsql2shp PostGIS command
      1. How to do it...
      2. How it works...
    8. Importing OpenStreetMap data with the osm2pgsql command
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Importing raster data with the raster2pgsql PostGIS command
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Importing multiple rasters at a time
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Exporting rasters with the gdal_translate and gdalwarp GDAL commands
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  7. Structures That Work
    1. Introduction
    2. Using geospatial views
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Using triggers to populate the geometry column
      1. Getting ready
      2. How to do it...
      3. There's more...
        1. Extending further...
      4. See also
    4. Structuring spatial data with table inheritance
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Extending inheritance – table partitioning
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Normalizing imports
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Normalizing internal overlays
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    8. Using polygon overlays for proportional census estimates
      1. Getting ready
      2. How to do it...
      3. How it works...
  8. Working with Vector Data – The Basics
    1. Introduction
    2. Working with GPS data
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Fixing invalid geometries
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. GIS analysis with spatial joins
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Simplifying geometries
      1. How to do it...
      2. How it works...
    6. Measuring distances
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Merging polygons using a common attribute
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Computing intersections
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Clipping geometries to deploy data
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Simplifying geometries with PostGIS topology
      1. Getting ready
      2. How to do it...
      3. How it works...
  9. Working with Vector Data – Advanced Recipes
    1. Introduction
    2. Improving proximity filtering with KNN
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Improving proximity filtering with KNN – advanced
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Rotating geometries
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Improving ST_Polygonize
      1. Getting ready
      2. How to do it...
      3. See also
    6. Translating, scaling, and rotating geometries – advanced
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Detailed building footprints from LiDAR
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating a fixed number of clusters from a set of points
      1. Getting ready
      2. How to do it...
    9. Calculating Voronoi diagrams
      1. Getting ready
      2. How to do it...
  10. Working with Raster Data
    1. Introduction
    2. Getting and loading rasters
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Working with basic raster information and analysis
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Performing simple map-algebra operations
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Combining geometries with rasters for analysis
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Converting between rasters and geometries
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Processing and loading rasters with GDAL VRT
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Warping and resampling rasters
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Performing advanced map-algebra operations
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Executing DEM operations
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Sharing and visualizing rasters through SQL
      1. Getting ready
      2. How to do it...
      3. How it works...
  11. Working with pgRouting
    1. Introduction
    2. Startup – Dijkstra routing
      1. Getting ready
      2. How to do it...
    3. Loading data from OpenStreetMap and finding the shortest path using A*
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Calculating the driving distance/service area
      1. Getting ready
      2. How to do it...
      3. See also
    5. Calculating the driving distance with demographics
      1. Getting ready
      2. How to do it...
    6. Extracting the centerlines of polygons
      1. Getting ready
      2. How to do it...
      3. There's more...
  12. Into the Nth Dimension
    1. Introduction
    2. Importing LiDAR data
      1. Getting ready
      2. How to do it...
      3. See also
    3. Performing 3D queries on a LiDAR point cloud
      1. How to do it...
    4. Constructing and serving buildings 2.5D
      1. Getting ready
      2. How to do it...
    5. Using ST_Extrude to extrude building footprints
      1. How to do it...
    6. Creating arbitrary 3D objects for PostGIS
      1. Getting ready
      2. How to do it...
    7. Exporting models as X3D for the web
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Reconstructing Unmanned Aerial Vehicle (UAV) image footprints with PostGIS 3D
      1. Getting started
      2. How to do it...
    9. UAV photogrammetry in PostGIS – point cloud
      1. Getting ready
      2. How to do it...
    10. UAV photogrammetry in PostGIS – DSM creation
      1. Getting ready
      2. How to do it...
  13. PostGIS Programming
    1. Introduction
    2. Writing PostGIS vector data with Psycopg
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Writing PostGIS vector data with OGR Python bindings
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Writing PostGIS functions with PL/Python
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Geocoding and reverse geocoding using the GeoNames datasets
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Geocoding using the OSM datasets with trigrams
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Geocoding with geopy and PL/Python
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Importing NetCDF datasets with Python and GDAL
      1. Getting ready
      2. How to do it...
      3. How it works...
  14. PostGIS and the Web
    1. Introduction
    2. Creating WMS and WFS services with MapServer
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Creating WMS and WFS services with GeoServer
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Creating a WMS Time service with MapServer
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Consuming WMS services with OpenLayers
      1. Getting ready
      2. How to do it...
      3. How it works..
    6. Consuming WMS services with Leaflet
      1. How to do it...
      2. How it works...
    7. Consuming WFS-T services with OpenLayers
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Developing web applications with GeoDjango – part 1
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Developing web applications with GeoDjango – part 2
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Developing a web GPX viewer with Mapbox
      1. How to do it...
      2. How it works...
  15. Maintenance, Optimization, and Performance Tuning
    1. Introduction
    2. Organizing the database
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Setting up the correct data privilege mechanism
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Backing up the database
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Using indexes
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Clustering for efficiency
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Optimizing SQL queries
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Migrating a PostGIS database to a different server
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Replicating a PostGIS database with streaming replication
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Geospatial sharding
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Paralellizing in PosgtreSQL
      1. Getting ready
      2. How to do it...
      3. How it works...
  16. Using Desktop Clients
    1. Introduction
    2. Adding PostGIS layers – QGIS
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Using the Database Manager plugin – QGIS
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Adding PostGIS layers – OpenJUMP GIS
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Running database queries – OpenJUMP GIS
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Adding PostGIS layers – gvSIG
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Adding PostGIS layers – uDig
      1. How to do it...
      2. How it works...
  17. Introduction to Location Privacy Protection Mechanisms
    1. Introduction
      1. Definition of Location Privacy Protection Mechanisms – LPPMs
      2. Classifying LPPMs
    2. Adding noise to protect location data
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Creating redundancy in geographical query results
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. References
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: PostGIS Cookbook - Second Edition
  • Author(s): Mayra Zurbaran, Pedro M. Wightman, Paolo Corti, Stephen Vincent Mather, Thomas J Kraft
  • Release date: March 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788299329