PostGIS Cookbook

PostGIS Cookbook

Paolo Corti, Stephen Vincent Mather, Thomas J. Kraft, Bborie Park

Language: English

Pages: 484


Format: PDF / Kindle (mobi) / ePub

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

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.


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.







, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Chapter 1: Moving Data In and Out of PostGIS 7 Introduction 7 Importing nonspatial tabular data (CSV) using PostGIS functions 7 Importing nonspatial tabular data (CSV) using GDAL 12 Importing shapefiles with shp2pgsql 17 Importing and exporting data with the ogr2ogr GDAL command 21 Handling batch importing and

./ Importing earthquakes with magnitude 1 to chp03.earthquakes PostGIS table... Importing earthquakes with magnitude 2 to chp03.earthquakes PostGIS table... ... 5. To maintain consistency with the book's conventions, rename the geometric column wkb_geometry (the default geometry output name in ogr2ogr) to the_geom, as illustrated in the following command: postgis_cookbook=# ALTER TABLE chp03.earthquakes RENAME wkb_ geometry TO the_geom; 6. Download the cities shapefile for USA

you should make the calculations taking into consideration the earth's curvature. For example, the previously used Mercator planar system, while it is very good to use for map outputs, is very bad for measuring distances and areas, as it assesses directions. For this purpose, it would be better to use a spatial reference system that is able to measure distance. You can also use the ST_Distance_Sphere or ST_Distance_Spheroid functions (the first being quicker, but less accurate, as it performs

include all of the required dependencies of PostGIS. The minimum required dependencies for PostGIS are PROJ.4, GEOS, libjson, and GDAL. A basic understanding of the SQL language is required to understand and adapt the code found in this book's recipes. Who this book is for This book is written for those who are looking for the best method to solve their spatial problems using PostGIS. These problems can be as simple as finding the nearest restaurant to a specific location or as complex as

index_query as (SELECT ST_Distance($1,road.geom) as dist, degrees(ST_Azimuth($1, ST_ ClosestPoint(road.geom, $1))) as azimuth FROM street_centerlines As road ORDER BY $1 <#> road.geom LIMIT 5) 136 Chapter 4 Note that we are actually returning two columns. The first column is dist in which we calculate the distance to the nearest five road lines. Note that this operation is performed after the ORDER BY and LIMIT functions have been used as filters, so this does not take much computation. Then,

Download sample