logo资料库

Mastering PostGIS.pdf

第1页 / 共321页
第2页 / 共321页
第3页 / 共321页
第4页 / 共321页
第5页 / 共321页
第6页 / 共321页
第7页 / 共321页
第8页 / 共321页
资料共321页,剩余部分请下载后查看
Cover
Copyright
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Importing Spatial Data
Obtaining test data
Setting up the database
Importing flat data
Importing data using psql
Importing data interactively
Importing data non-interactively
Importing data using pgAdmin
Extracting spatial information from flat data
Importing shape files using shp2pgsql
shp2pgsql in cmd
The shp2pgsql GUI version
Importing vector data using ogr2ogr
Importing GML
Importing MIF and TAB
Importing KML
ogr2ogr GUI (Windows only)
Importing data using GIS clients
Exporting a shapefile to PostGIS using QGIS and SPIT
Exporting shapefile to PostGIS using QGIS and DbManager
Exporting spatial data to PostGIS from Manifold GIS
Importing OpenStreetMap data
Connecting to external data sources with foreign data wrappers
Connecting to SQL Server Spatial
Connecting to WFS service
Loading rasters using raster2pgsql
Importing a single raster
Importing multiple rasters
Importing data with pgrestore
Summary
Chapter 2: Spatial Data Analysis
Composing and decomposing geometries
Creating points
Extracting coordinates from points
Composing and decomposing Multi-geometries
Multi-geometry decomposition
Composing and decomposing LineStrings
LineString composition
LineString decomposition
Composing and decomposing polygons
Polygon composition
Polygon decomposition
Spatial measurement
General warning - mind the SRID!
Measuring distances between two geometries
Measuring the length, area, and perimeter of geometries
Line length
Polygon perimeter
Polygon area
Geometry bounding boxes
Accessing bounding boxes
Creating bounding boxes
Using bounding boxes in spatial queries
Geometry simplification
Geometry validation
Simplicity and validity
Testing for simplicity and validity
Checking for validity
Repairing geometry errors
Validity constraint
Intersecting geometries
Nearest feature queries
Summary
Chapter 3: Data Processing - Vector Ops
Primer - obtaining and importing OpenStreetMap data
Merging geometries
Merging polygons
Merging MultiLineStrings
Slicing geometries
Splitting a polygon by LineString
Splitting a LineString with another LineString
Extracting a section of LineString
Buffering and offsetting geometries
Offsetting features
Creating convex and concave hulls
Computing centroids, points-on-surface, and points-on-line
Reprojecting geometries
Spatial relationships
Touching
Crossing
Overlapping
Containing
Radius queries
Summary
Chapter 4: Data Processing - Raster Ops
Preparing data
Processing and analysis
Analytic and statistical functions
Vector to raster conversion
Raster to vector conversion
Spatial relationship
Metadata
Summary
Chapter 5: Exporting Spatial Data
Exporting data using \COPY in psql
Exporting data in psql interactively
Exporting data in psql non-interactively
Exporting data in PgAdmin
Exporting vector data using pgsql2shp
pgsql2sph command line
pgsql2shp gui
Exporting vector data using ogr2ogr
Exporting KML revisited
Exporting SHP
Exporting MapInfo TAB and MIF
Exporting to SQL Server
ogr2ogr GUI
Exporting data using GIS clients
Exporting data using QGIS
Exporting data using Manifold.
Outputting rasters using GDAL
Outputting raster using psql
Exporting data using the PostgreSQL backup functionality
Summary
Chapter 6: ETL Using Node.js
Setting up Node.js
Making a simple Node.js hello world in the command line
Making a simple HTTP server
Handshaking with a database using Node.js PgSQL client
Retrieving and processing JSON data
Importing shapefiles revisited
Consuming JSON data
Geocoding address data
Consuming WFS data
Summary
Chapter 7: PostGIS – Creating Simple WebGIS Applications
ExtJS says Hello World
Configuring GeoServer web services
Importing test data
Outputting vector data as WMS services in GeoServer
Outputting raster data as WMS services in GeoServer
Outputting vector data as WFS services
Making use of PgRaster in a simple WMS GetMap handler
Consuming WMS
Consuming WMS in ol3
Consuming WMS in Leaflet
Enabling CORS in Jetty
Consuming WFS in ol3
Outputting and consuming GeoJSON
Consuming GeoJSON in ol3
Consuming GeoJSON in Leaflet
Outputting and consuming TopoJSON
Consuming TopoJSON in ol3
Consuming TopoJSON in Leaflet
Implementing a simple CRUD application that demonstrates vector editing via web interfaces
WebGIS CRUD server in Node.js
WebGIS CRUD client
Layer manager
Drawing tools
Analysis tools - buffering
Summary
Chapter 8: PostGIS Topology
The conceptual model
The data
Installation
Creating an empty topology
Importing Simple Feature data into topology
Checking the validity of input geometries
Creating a TopoGeometry column and a topology layer
Populating a TopoGeometry column from an existing geometry
Inspecting and validating a topology
Topology validation
Accessing the topology data
Querying topological elements by a point
Locating nodes
Locating edges
Locating faces
Topology editing
Adding new elements
Creating TopoGeometries
Splitting and merging features
Splitting features
Merging features
Updating edge geometry
Topology-aware simplification
Importing sample data
Topology output
GML output
TopoJSON output
Summary
Chapter 9: pgRouting
Installing the pgRouting extension
Importing routing data
Importing shapefiles
Importing OSM data using osm2pgrouting
pgRouting algorithms
All pairs shortest path
Shortest path
Shortest path Dijkstra
A-Star (A*)
K-Dijkstra
K-Shortest path
Turn restrictions shortest path (TRSP)
Driving distance
Traveling sales person
Handling one-way edges
Consuming pgRouting functionality in a web app
Summary
Index
i i D o m n k M k e w c z , i i i i M c h a l i M a c k e w c z , i T o m a s z N y c z M a s t e r i n g P o s t G S I Dominik Mikiewicz, Michal Mackiewicz, Tomasz Nycz Mastering PostGIS Create, deliver, and consume spatial data using PostGIS Mastering PostGIS PostGIS is open source extension of 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 the functionalities offered by PostGIS, from data creation, analysis, and output, to ETL and live edits. to help you master is The book begins with an overview of the key concepts related to spatial database systems. You will learn to load different formats instance, investigate the spatial nature of your raster data, and fi nally export it using built-in functionalities or third-party tools for backup or representational purposes. into your Postgres Through the course of this book, you will be presented with many examples of 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. Things you will learn: • Refresh your knowledge of 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 $ 34.49 US £ 28.37 UK www.packtpub.com Prices do not include local sales Tax or VAT where applicable
Mastering PostGIS Create, deliver, and consume spatial data using PostGIS Dominik Mikiewicz Michal Mackiewicz Tomasz Nycz BIRMINGHAM - MUMBAI
Mastering PostGIS Copyright © 2017 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: May 2017 Production reference: 1260517 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78439-164-5 www.packtpub.com
Credits Authors Dominik Mikiewicz Michal Mackiewicz Tomasz Nycz Reviewers Prashant Verma Eric Pimpler Copy Editor Safis Editing Project Coordinator Nidhi Joshi Commissioning Editor Amey Varangaonkar Proofreader Safis Editing Acquisition Editor Vinay Argekar Indexer Mariammal Chettiyar Content Development Editor Mayur Pawanikar Graphics Tania Dutta Technical Editor Dinesh Chaudhary Production Coordinator Aparna Bhagat  
About the Authors Dominik Mikiewicz is a senior GIS consultant and the owner of one-person software shop Cartomatic. When not coding, he spends time with wife and kids, trying to make the little ones enjoy mountain trekking. He is also a long-distance cycling and running enthusiast. Michal Mackiewicz has been working as a software engineer at GIS Support for five years. His main job is to orchestrate various open source geospatial components and creating application-specific GIS systems. PostgreSQL and PostGIS are among his favorite tools, and are used in almost every project. Apart from developing, he also runs PostGIS training courses. When not at work, he volunteers for OpenStreetMap and a local railway preservation society. Tomasz Nycz is a geographer and cartographer. He initiated the implementation of GIS in the State Fire Service units in Poland. He works with recognized GIS companies in the emergency management industry. In practice, he uses QGIS and PostGIS. He has been an OpenStreetMap contributor for years. He also develops his scientific interests in the use of new technologies in geomorphology and remote sensing. He is also an avid drone pilot and mountain explorer.
About the Reviewers Eric Pimpler is the founder and owner of GeoSpatial Training Services (geospatialtraining.com) and has over 20 years of experience in implementing and teaching GIS solutions using Esri, Google Earth/Maps, and open source technology. Currently, he focuses on ArcGIS scripting with Python and the development of custom ArcGIS Server web and mobile applications using JavaScript. He is the author of Programming ArcGIS 10.1 with Python Cookbook. Eric has a bachelor's degree in Geography from Texas A&M University and a master's degree in Applied Geography with a concentration in GIS from Texas State University. Prashant Verma started his IT carrier in 2011 as a Java developer at Ericsson working in the telecoms domain. After a couple of years of Java EE experience, he moved into the big data domain, and has worked on almost all the popular big data technologies, such as Hadoop, Spark, Flume, Mongo, and Cassandra. He has also played with Scala. Currently, he works with QA Infotech as lead data engineer, working on solving e-Learning problems using analytics and machine learning. Prashant has also worked on Apache Spark for Java Developers as a technical reviewer. I want to thank Packt Publishing for giving me the chance to review the book, as well as my employer and my family for their patience while I was busy working on this book.
www.PacktPub.com For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. h t t p s ://w w w . p a c k t p u b . c o m /m a p t Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser
Customer Feedback Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1784391646. If you'd like to join our team of regular reviewers, you can e-mail us at customerreviews@packtpub.com. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
分享到:
收藏