ebook img

Geoprocessing with Python PDF

362 Pages·2016·28.17 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Geoprocessing with Python

Chris Garrard M A N N I N G Geoprocessing with Python ii Geoprocessing with Python CHRIS GARRARD MANNING SHELTER ISLAND iv 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] ©2016 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 elemental chlorine. Manning Publications Co. Development editor: Jennifer Stout 20 Baldwin Road Technical development editor: Karsten Strøbæk PO Box 761 Copyeditor: Katie Petito Shelter Island, NY 11964 Proofreader: Katie Tennant Technical proofreader: Rizwan Bilbul Typesetter: Marija Tudor Cover designer: Marija Tudor ISBN: 9781617292149 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – EBM – 21 20 19 18 17 16 brief contents 1 ■ Introduction 1 2 ■ Python basics 15 3 ■ Reading and writing vector data 35 4 ■ Working with different vector file formats 67 5 ■ Filtering data with OGR 88 6 ■ Manipulating geometries with OGR 105 7 ■ Vector analysis with OGR 129 8 ■ Using spatial reference systems 153 9 ■ Reading and writing raster data 173 10 ■ Working with raster data 208 11 ■ Map algebra with NumPy and SciPy 237 12 ■ Map classification 276 13 ■ Visualizing data 287 v vi BRIEF CONTENTS contents preface xi acknowledgments xiii about this book xiv about the author xvii about the cover illustration xviii 1 Introduction 1 1.1 Why use Python and open source? 2 1.2 Types of spatial data 3 1.3 What is geoprocessing? 7 1.4 Exploring your data 10 1.5 Summary 14 2 Python basics 15 2.1 Writing and executing code 16 2.2 Basic structure of a script 17 2.3 Variables 18 2.4 Data types 20 Booleans 20 ■ Numeric types 20 ■ Strings 22 Lists and tuples 24 ■ Sets 26 ■ Dictionaries 26 2.5 Control flow 27 If statements 27 ■ While statements 29 ■ For statements 29 ■ break, continue, and else 30 2.6 Functions 31 2.7 Classes 32 2.8 Summary 34 vii viii CONTENTS 3 Reading and writing vector data 35 3.1 Introduction to vector data 36 3.2 Introduction to OGR 41 3.3 Reading vector data 44 Accessing specific features 47 ■ Viewing your data 49 3.4 Getting metadata about the data 51 3.5 Writing vector data 54 Creating new data sources 59 ■ Creating new fields 61 3.6 Updating existing data 63 Changing the layer definition 63 ■ Adding, updating, and deleting features 64 3.7 Summary 66 4 Working with different vector file formats 67 4.1 Vector file formats 68 File-based formats such as shapefiles and geoJSON 68 Multi-user database formats such as PostGIS 71 4.2 Working with more data formats 71 SpatiaLite 72 ■ PostGIS 73 ■ Folders as data sources (shapefiles and CSV) 74 ■ Esri file geodatabases 74 Web feature services 76 4.3 Testing format capabilities 84 4.4 Summary 87 5 Filtering data with OGR 88 5.1 Attribute filters 89 5.2 Spatial filters 93 5.3 Using SQL to create temporary layers 99 5.4 Taking advantage of filters 103 5.5 Summary 104 6 Manipulating geometries with OGR 105 6.1 Introduction to geometries 106 6.2 Working with points 107 Creating and editing single points 108 ■ Creating and editing multipoints: multiple points as one geometry 110 6.3 Working with lines 112 Creating and editing single lines 114 ■ Creating and editing multilines: multiple lines as one geometry 118 CONTENTS ix 6.4 Working with polygons 120 Creating and editing single polygons 122 ■ Creating and editing multipolygons: multiple polygons as one geometry 124 Creating and editing polygons with holes: donuts 126 6.5 Summary 128 7 Vector analysis with OGR 129 7.1 Overlay tools: what’s on top of what? 130 7.2 Proximity tools: how far apart are things? 136 7.3 Example: locating areas suitable for wind farms 140 7.4 Example: animal tracking data 144 7.5 Summary 152 8 Using spatial reference systems 153 8.1 Introduction to spatial reference systems 154 8.2 Using spatial references with OSR 159 Spatial reference objects 159 ■ Creating spatial reference objects 161 ■ Assigning an SRS to data 163 ■ Reprojecting geometries 164 ■ Reprojecting an entire layer 167 8.3 Using spatial references with pyproj 168 Transforming coordinates between spatial reference systems 169 Great-circle calculations 171 8.4 Summary 172 9 Reading and writing raster data 173 9.1 Introduction to raster data 174 9.2 Introduction to GDAL 181 9.3 Reading partial datasets 187 Using real-world coordinates 193 ■ Resampling data 196 9.4 Byte sequences 200 9.5 Subdatasets 203 9.6 Web map services 204 9.7 Summary 207 10 Working with raster data 208 10.1 Ground control points 209 10.2 Converting pixel coordinates to another image 213 10.3 Color tables 215 Transparency 217

Description:
Summary Geoprocessing with Python teaches you how to use the Python programming language, along with free and open source tools, to read, write, and process geospatial data. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Technol
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.