IN ACTION SECOND EDITION Regina O. Obe Leo S. Hsu FOREWORD BY PAUL RAMSEY M A N N I N G Praise for the First Edition of PostGIS in Action All PostGIS users, from novices to experts, will benefit from this book. Don’t use Post- GIS without it! —Brent Wood, NIWA An elegant introduction to a difficult domain. —Mark Leslie, LISAsoft Pty Ltd. It’s next to impossible to explain geospatial SQL succinctly, but this book pulls it off! —Andy Saurin, Saurin Solutions A great guide for the beginner and a great reference for the advanced user. —Bruce Rindahl, Ventura County Watershed Protection District Required reading for anyone wanting to get the most out of PostGIS. —James Fee, WeoGeo.com The must-have guide if you aim to do any serious professional PostGIS development. —Paolo Corti, European Forest Fire Information System (EFFIS) If you don’t understand the benefits of PostGIS, this book will give you the Aha! moment you have been waiting for. It is the most comprehensive book of its kind. —Jeff Addison, Southgate Software Ltd. This is the PostGIS reference I’ve always wished for. —Bill Dollins, Zekiah Technologies, Inc. Licensed to tracy moore <[email protected]> Licensed to tracy moore <[email protected]> PostGIS in Action SECOND EDITION REGINA O. OBE LEO S. HSU MANNING SHELTER ISLAND Licensed to tracy moore <[email protected]> For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: [email protected] ©2015 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Development editor: Jeff Bleiel 20 Baldwin Road Technical development editor: Deepak Vohra PO Box 761 Copyeditors: Benjamin Berg, Andy Carroll Shelter Island, NY 11964 Proofreader: Katie Tennant Technical proofreader: David Pombal Typesetter: Dottie Marsico Cover designer: Marija Tudor ISBN 9781617291395 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – EBM – 20 19 18 17 16 15 Licensed to tracy moore <[email protected]> To Dr. Ernest Olagbade Obe (1935–2012), professor, chief, daddy Licensed to tracy moore <[email protected]> Licensed to tracy moore <[email protected]> brief contents PART 1 INTRODUCTION TO POSTGIS........................................1 1 ■ What is a spatial database? 3 2 ■ Spatial data types 27 3 ■ Spatial reference system considerations 60 4 ■ Working with real data 82 5 ■ Using PostGIS on the desktop 113 6 ■ Geometry and geography functions 140 7 ■ Raster functions 175 8 ■ PostGIS TIGER geocoder 203 9 ■ Geometry relationships 218 PART 2 PUTTING POSTGIS TO WORK ....................................245 10 ■ Proximity analysis 247 11 ■ Geometry and geography processing 261 12 ■ Raster processing 287 13 ■ Building and using topologies 309 14 ■ Organizing spatial data 337 15 ■ Query performance tuning 369 vii Licensed to tracy moore <[email protected]> viii BRIEF CONTENTS PART 3 USING POSTGIS WITH OTHER TOOLS ........................407 16 ■ Extending PostGIS with pgRouting and procedural languages 409 17 ■ Using PostGIS in web applications 442 Licensed to tracy moore <[email protected]> contents foreword xix preface xxi acknowledgments xxii about this book xxiv PART 1 INTRODUCTION TO POSTGIS...............................1 1 What is a spatial database? 3 1.1 Thinking spatially 4 1.2 Introducing PostGIS 6 Why PostGIS 7 ■ Alternatives to PostGIS 10 ■ Installing PostGIS 12 1.3 Spatial data types 14 Geometry type 15 ■ Geography type 15 ■ Raster type 16 Topology type 17 1.4 Hello real world 17 Digesting the problem 18 ■ Modeling 19 ■ Loading data 21 Writing the query 24 ■ Viewing spatial data with OpenJump 25 1.5 Summary 26 ix Licensed to tracy moore <[email protected]>
Description: