Spectral Python
Total Page:16
File Type:pdf, Size:1020Kb
Learning Geospatial Analysis with Python Master GIS and Remote Sensing analysis using Python with these easy to follow tutorials Joel Lawhead BIRMINGHAM - MUMBAI Learning Geospatial Analysis with Python Copyright © 2013 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, 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: October 2013 Production Reference: 1181013 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78328-113-8 www.packtpub.com Cover Image by Jarek Blaminsky ([email protected]) Credits Author Project Coordinator Joel Lawhead Angel Jathanna Reviewers Proofreader Jorge Samuel Mendes de Jesus Bernadette Watkins Athanasios Tom Kralidis Alessandro Pasotti Indexer Hemangini Bari Acquisition Editor Joanne Fitzpatrick Graphics Abhinash Sahu Lead Technical Editor Balaji Naidu Production Coordinator Shantanu Zagade Technical Editors Pooja Arondekar Cover Work Shantanu Zagade Anita Nayak Anusri Ramchandran About the Author Joel Lawhead is a PMI-certified Project Management Professional (PMP) and the Chief Information Officer (CIO) for NVisionSolutions.com, an award-winning firm specializing in geospatial technology integration and sensor engineering. He began using Python in 1997 and began combining it with geospatial software development in 2000. He has been published in two editions of the Python Cookbook by O'Reilly. He is also the developer of the widely used open source Python Shapefile Library (PyShp) and maintains the geospatial technical blog GeospatialPython.com and Twitter feed @SpatialPython discussing the use of the Python programming language within the geospatial industry. In 2011, he reverse engineered and published the undocumented shapefile spatial indexing format and assisted fellow geospatial Python developer, Marc Pfister, in reversing the algorithm used, allowing developers around the world to create better-integrated and more robust geospatial applications involving shapefiles. He has served as the lead architect, project manager, and co-developer for geospatial applications used by US government agencies including NASA, FEMA, NOAA, the US Navy, as well as many commercial and non-profit organizations. In 2002, he received the international "Esri Special Achievment in GIS" award for work on the Real-time Emergency Action Coordination Tool (REACT) for emergency management using geospatial analysis. I would like to acknowledge my loving family including my wife Julie and four children Lauren, Will, Lillie, and Lainie who allowed me to write this book after hours. Thank you to my parents who inspired me through their actions to pursue computers, teaching, and writing; all the ingredients needed for a technical book. I would also like to acknowledge the work of the geospatial Python pioneers whose relentless and selfless contributions over the years in developing and publishing code to the geospatial Python body of knowledge made the content of this book possible, including Sean Gillies, Howard Butler, Matthew Perry, Frank Warmerdam, and Marc Pfister. About the Reviewers Jorge Samuel Mendes de Jesus has 15 years of programming experience in the field of Geoinformatics, with focus on Python programming, web services, and spatial databases. He has a PhD in Geography and Sustainable Development from Ben-Gurion University and has been employed by the Joint Research Center, ISPRA, Plymouth Marine Laboratory and currently works at ISRIC, World Soil Information. He currently lives in Wageningen, the Netherlands and spends his time learning combat sports and Dutch. Athanasios Tom Kralidis is a Senior Systems Scientist for the Meteorological Service of Canada, where he provides geospatial technical and architectural leadership in support of MSC's data. His professional background includes key involvement in the development and integration of geospatial web standards, systems and services for the Canadian Geospatial Data Infrastructure (CGDI) with Natural Resources Canada (NRCan), as well as using these principles in architecting RésEau, Canada's water information portal. He is active in the Open Geospatial Consortium (OGC) community, was lead contributer to the OGC Web Map Context Documents Specification, member of the CGDI Architecture Advisory Board, as well as part of the Canadian Advisory Committee to ISO Technical Committee 211 Geographic Information / Geomatics. He is a developer on the MapServer, GeoNode and OWSLib open source software projects, and part of the MapServer Project Steering Committee. He is the founder and lead developer of pycsw, an OGC-compliant CSW reference implementation. He is also a charter member of the OGC. Tom holds a Bachelor's degree in Geography from York University, GIS certification from Algonquin College, and a Master's degree in Geography and Environmental Studies (research and dissertation in Geospatial Web Services / Infrastructure) from Carleton University. He is a Certified Geomatics Specialist (GIS/LIS) with the Canadian Institute of Geomatics. Alessandro Pasotti is the founder of ItOpen, an Italian web development consultancy focused on web GIS development and accessible websites. He has been programming for over two decades and he is now mainly a web application developer, handling both frontend and backend development. He fell in love with Linux and free software in 1994 and never turned back. He spends most of his time developing web GIS applications in Python using GeoDjango and JavaScript mapping libraries such as OpenLayers. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. 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 [email protected] 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. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, 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: Learning Geospatial Analysis with Python 9 Geospatial analysis and our world 9 Beyond politics 12 History of geospatial analysis 13 Geographic Information Systems 17 Remote sensing 18 Elevation data 24 Computer-aided drafting 25 Geospatial analysis and computer programming 26 Object-oriented programming for geospatial analysis 27 Importance of geospatial analysis 28 Geographic Information System concepts 29 Thematic maps 30 Spatial databases 31 Spatial indexing 32 Metadata 32 Map projections 32 Rendering 33 Raster data concepts 34 Images as data 35 Remote sensing and color 35 Common vector GIS concepts 36 Data structures 36 Buffer 38 Dissolve 38 Generalize 39 Intersection 40 Table of Contents Merge 40 Point in polygon 41 Union 42 Join 42 Geospatial rules about polygons 43 Common raster data concepts 43 Band math 43 Change detection 44 Histogram 45 Feature extraction 45 Supervised classification 46 Unsupervised classification 46 Creating the simplest possible Python GIS 46 Getting started with Python 46 Building SimpleGIS 47 Summary 55 Chapter 2: Geospatial Data 57 Data structures 61 Common traits 61 Geo-location 61 Subject information 61 Spatial indexing 62 Metadata 65 File structure 66 Vector data 72 Shapefiles 74 CAD files 76 Tag and markup-based formats 77 GeoJSON 79 Raster data 80 TIFF files 81 JPEG, GIF, BMP, and PNG 81 Compressed formats 82 ASCII GRIDS 82 World files 83 Point cloud data 85 Summary 87 Chapter 3: The Geospatial Technology Landscape 89 Data access 92 GDAL 92 OGR 93 [ ii ] Table of Contents Computational geometry 95 PROJ.4 96 CGAL 97 JTS 98 GEOS 100 PostGIS 101 Other spatially-enabled databases 104 Oracle spatial and graph 105 ArcSDE 107 Microsoft SQL Server 109 MySQL 109 SpatiaLite 109 Routing 110 Esri Network Analyst and Spatial Analyst 110 pgRouting 110 Desktop tools 111 Quantum GIS 112 OpenEV 113 GRASS GIS 115 uDig 116 gvSIG 118 OpenJUMP 118 Google Earth 118 NASA World Wind 120 ArcGIS 122 Metadata