0%

Book Description

Write efficient GIS applications using PostGIS - from data creation to data consumption

About This Book

  • Learn how you can use PostGIS for spatial data analysis and manipulation
  • Optimize your queries and build custom functionalities for your GIS application
  • A comprehensive guide with hands-on examples to help you master PostGIS with ease

Who This Book Is For

If you are a GIS developer or analyst who wants to master PostGIS to build efficient, scalable GIS applications, this book is for you. If you want to conduct advanced analysis of spatial data, this book will also help you. The book assumes that you have a working installation of PostGIS in place, and have working experience with PostgreSQL.

What You Will Learn

  • Refresh your knowledge of the PostGIS concepts and spatial databases
  • Solve spatial problems with the use of SQL in real-world scenarios
  • Practical walkthroughs of application development examples using Postgis, GeoServer and OpenLayers.
  • Extract, transform and load your spatial data
  • Expose data directly or through web services.
  • Consume your data in both desktop and web clients

In Detail

PostGIS is open source extension onf PostgreSQL object-relational database system that allows GIS objects to be stored and allows querying for information and location services. The aim of this book is to help you master the functionalities offered by PostGIS- from data creation, analysis and output, to ETL and live edits.

The book begins with an overview of the key concepts related to spatial database systems and how it applies to Spatial RMDS. You will learn to load different formats into your Postgres instance, investigate the spatial nature of your raster data, and finally export it using built-in functionalities or 3th party tools for backup or representational purposes.

Through the course of this book, you will be presented with many examples on how to interact with the database using JavaScript and Node.js. Sample web-based applications interacting with backend PostGIS will also be presented throughout the book, so you can get comfortable with the modern ways of consuming and modifying your spatial data.

Style and approach

This book is a comprehensive guide covering all the concepts you need to master PostGIS. Packed with hands-on examples, tips and tricks, even the most advanced concepts are explained in a very easy-to-follow manner. Every chapter in the book does not only focus on how each task is performed, but also why.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Importing Spatial Data
    1. Obtaining test data
      1. Setting up the database
    2. Importing flat data
      1. Importing data using psql
        1. Importing data interactively
        2. Importing data non-interactively
      2. Importing data using pgAdmin
      3. Extracting spatial information from flat data
    3. Importing shape files using shp2pgsql
      1. shp2pgsql in cmd
      2. The shp2pgsql GUI version
    4. Importing vector data using ogr2ogr
      1. Importing GML
      2. Importing MIF and TAB
      3. Importing KML
      4. ogr2ogr GUI (Windows only)
    5. Importing data using GIS clients
      1. Exporting a shapefile to PostGIS using QGIS and SPIT
      2. Exporting shapefile to PostGIS using QGIS and DbManager
      3. Exporting spatial data to PostGIS from Manifold GIS
    6. Importing OpenStreetMap data
    7. Connecting to external data sources with foreign data wrappers
      1. Connecting to SQL Server Spatial
      2. Connecting to WFS service
    8. Loading rasters using raster2pgsql
      1. Importing a single raster
      2. Importing multiple rasters
    9. Importing data with pgrestore
    10. Summary
  3. Spatial Data Analysis
    1. Composing and decomposing geometries
      1. Creating points
      2. Extracting coordinates from points
      3. Composing and decomposing Multi-geometries
        1. Multi-geometry decomposition
      4. Composing and decomposing LineStrings
        1. LineString composition
        2. LineString decomposition
      5. Composing and decomposing polygons
        1. Polygon composition
        2. Polygon decomposition
    2. Spatial measurement
      1. General warning - mind the SRID!
      2. Measuring distances between two geometries
      3. Measuring the length, area, and perimeter of geometries
        1. Line length
        2. Polygon perimeter
        3. Polygon area
    3. Geometry bounding boxes
      1. Accessing bounding boxes
      2. Creating bounding boxes
      3. Using bounding boxes in spatial queries
    4. Geometry simplification
    5. Geometry validation
      1. Simplicity and validity
      2. Testing for simplicity and validity
        1. Checking for validity
      3. Repairing geometry errors
      4. Validity constraint
    6. Intersecting geometries
    7. Nearest feature queries
    8. Summary
  4. Data Processing - Vector Ops
    1. Primer - obtaining and importing OpenStreetMap data
    2. Merging geometries
      1. Merging polygons
      2. Merging MultiLineStrings
    3. Slicing geometries
      1. Splitting a polygon by LineString
      2. Splitting a LineString with another LineString
      3. Extracting a section of LineString
    4. Buffering and offsetting geometries
      1. Offsetting features
      2. Creating convex and concave hulls
      3. Computing centroids, points-on-surface, and points-on-line
    5. Reprojecting geometries
    6. Spatial relationships
      1. Touching
      2. Crossing
      3. Overlapping
      4. Containing
      5. Radius queries
    7. Summary
  5. Data Processing - Raster Ops
    1. Preparing data
    2. Processing and analysis
    3. Analytic and statistical functions
    4. Vector to raster conversion
    5. Raster to vector conversion
    6. Spatial relationship
    7. Metadata
    8. Summary
  6. Exporting Spatial Data
    1. Exporting data using COPY in psql
      1. Exporting data in psql interactively
      2. Exporting data in psql non-interactively
      3. Exporting data in PgAdmin
    2. Exporting vector data using pgsql2shp
      1. pgsql2sph command line
      2. pgsql2shp gui
    3. Exporting vector data using ogr2ogr
      1. Exporting KML revisited
      2. Exporting SHP
      3. Exporting MapInfo TAB and MIF
      4. Exporting to SQL Server
      5. ogr2ogr GUI
    4. Exporting data using GIS clients
      1. Exporting data using QGIS
      2. Exporting data using Manifold.
    5. Outputting rasters using GDAL
    6. Outputting raster using psql
    7. Exporting data using the PostgreSQL backup functionality
    8. Summary
  7. ETL Using Node.js
    1. Setting up Node.js
      1. Making a simple Node.js hello world in the command line
      2. Making a simple HTTP server
    2. Handshaking with a database using Node.js PgSQL client
    3. Retrieving and processing JSON data
      1. Importing shapefiles revisited
      2. Consuming JSON data
    4. Geocoding address data
    5. Consuming WFS data
    6. Summary
  8. PostGIS – Creating Simple WebGIS Applications
    1. ExtJS says Hello World
    2. Configuring GeoServer web services
      1. Importing test data
      2. Outputting vector data as WMS services in GeoServer
        1. Outputting raster data as WMS services in GeoServer
      3. Outputting vector data as WFS services
    3. Making use of PgRaster in a simple WMS GetMap handler
    4. Consuming WMS
      1. Consuming WMS in ol3
      2. Consuming WMS in Leaflet
    5. Enabling CORS in Jetty
    6. Consuming WFS in ol3
    7. Outputting and consuming GeoJSON
      1. Consuming GeoJSON in ol3
      2. Consuming GeoJSON in Leaflet
    8. Outputting and consuming TopoJSON
      1. Consuming TopoJSON in ol3
      2. Consuming TopoJSON in Leaflet
    9. Implementing a simple CRUD application that demonstrates vector editing via web interfaces
      1. WebGIS CRUD server in Node.js
      2. WebGIS CRUD client
        1. Layer manager
        2. Drawing tools
        3. Analysis tools - buffering
    10. Summary
  9. PostGIS Topology
    1. The conceptual model
    2. The data
    3. Installation
    4. Creating an empty topology
    5. Importing Simple Feature data into topology
      1. Checking the validity of input geometries
      2. Creating a TopoGeometry column and a topology layer
      3. Populating a TopoGeometry column from an existing geometry
    6. Inspecting and validating a topology
      1. Topology validation
    7. Accessing the topology data
      1. Querying topological elements by a point
        1. Locating nodes
        2. Locating edges
        3. Locating faces
    8. Topology editing
      1. Adding new elements
      2. Creating TopoGeometries
      3. Splitting and merging features
        1. Splitting features
        2. Merging features
      4. Updating edge geometry
    9. Topology-aware simplification
      1. Importing sample data
    10. Topology output
      1. GML output
      2. TopoJSON output
    11. Summary
  10. pgRouting
    1. Installing the pgRouting extension
    2. Importing routing data
      1. Importing shapefiles
      2. Importing OSM data using osm2pgrouting
    3. pgRouting algorithms
      1. All pairs shortest path
      2. Shortest path
        1. Shortest path Dijkstra
        2. A-Star (A*)
        3. K-Dijkstra
        4. K-Shortest path
        5. Turn restrictions shortest path (TRSP)
      3. Driving distance
      4. Traveling sales person
        1. Handling one-way edges
    4. Consuming pgRouting functionality in a web app
    5. Summary