Geoprocessing with Python
brief contents
contents
preface
acknowledgments
about this book
Who should read this book
How this book is organized
About the code
Author Online
Other online resources
about the author
about the cover illustration
1 Introduction
1.1 Why use Python and open source?
1.2 Types of spatial data
1.3 What is geoprocessing?
1.4 Exploring your data
1.5 Summary
2 Python basics
2.1 Writing and executing code
2.2 Basic structure of a script
2.3 Variables
2.4 Data types
2.4.1 Booleans
2.4.2 Numeric types
2.4.3 Strings
2.4.4 Lists and tuples
2.4.5 Sets
2.4.6 Dictionaries
2.5 Control flow
2.5.1 If statements
2.5.2 While statements
2.5.3 For statements
2.5.4 break, continue, and else
2.6 Functions
2.7 Classes
2.8 Summary
3 Reading and writing vector data
3.1 Introduction to vector data
3.2 Introduction to OGR
3.3 Reading vector data
3.3.1 Accessing specific features
3.3.2 Viewing your data
3.4 Getting metadata about the data
3.5 Writing vector data
3.5.1 Creating new data sources
3.5.2 Creating new fields
3.6 Updating existing data
3.6.1 Changing the layer definition
3.6.2 Adding, updating, and deleting features
3.7 Summary
4 Working with different vector file formats
4.1 Vector file formats
4.1.1 File-based formats such as shapefiles and geoJSON
4.1.2 Multi-user database formats such as PostGIS
4.2 Working with more data formats
4.2.1 SpatiaLite
4.2.2 PostGIS
4.2.3 Folders as data sources (shapefiles and CSV)
4.2.4 Esri file geodatabases
4.2.5 Web feature services
4.3 Testing format capabilities
4.4 Summary
5 Filtering data with OGR
5.1 Attribute filters
5.2 Spatial filters
5.3 Using SQL to create temporary layers
5.4 Taking advantage of filters
5.5 Summary
6 Manipulating geometries with OGR
6.1 Introduction to geometries
6.2 Working with points
6.2.1 Creating and editing single points
6.2.2 Creating and editing multipoints: multiple points as one geometry
6.3 Working with lines
6.3.1 Creating and editing single lines
6.3.2 Creating and editing multilines: multiple lines as one geometry
6.4 Working with polygons
6.4.1 Creating and editing single polygons
6.4.2 Creating and editing multipolygons: multiple polygons as one geometry
6.4.3 Creating and editing polygons with holes: donuts
6.5 Summary
7 Vector analysis with OGR
7.1 Overlay tools: what’s on top of what?
7.2 Proximity tools: how far apart are things?
7.3 Example: locating areas suitable for wind farms
7.4 Example: animal tracking data
7.5 Summary
8 Using spatial reference systems
8.1 Introduction to spatial reference systems
8.2 Using spatial references with OSR
8.2.1 Spatial reference objects
8.2.2 Creating spatial reference objects
8.2.3 Assigning an SRS to data
8.2.4 Reprojecting geometries
8.2.5 Reprojecting an entire layer
8.3 Using spatial references with pyproj
8.3.1 Transforming coordinates between spatial reference systems
8.3.2 Great-circle calculations
8.4 Summary
9 Reading and writing raster data
9.1 Introduction to raster data
9.2 Introduction to GDAL
9.3 Reading partial datasets
9.3.1 Using real-world coordinates
9.3.2 Resampling data
9.4 Byte sequences
9.5 Subdatasets
9.6 Web map services
9.7 Summary
10 Working with raster data
10.1 Ground control points
10.2 Converting pixel coordinates to another image
10.3 Color tables
10.3.1 Transparency
10.4 Histograms
10.5 Attribute tables
10.6 Virtual raster format
10.6.1 Subsetting
10.6.2 Creating troublesome formats
10.6.3 Reprojecting images
10.7 Callback functions
10.8 Exceptions and error handlers
10.9 Summary
11 Map algebra with NumPy and SciPy
11.1 Introduction to NumPy
11.2 Map algebra
11.2.1 Local analyses
11.2.2 Focal analyses
11.2.3 Zonal analyses
11.2.4 Global analyses
11.3 Resampling data
11.4 Summary
12 Map classification
12.1 Unsupervised classification
12.2 Supervised classification
12.2.1 Accuracy assessments
12.3 Summary
13 Visualizing data
13.1 Matplotlib
13.1.1 Plotting vector data
13.1.2 Plotting raster data
13.1.3 Plotting 3D data
13.2 Mapnik
13.2.1 Drawing vector data
13.2.2 Storing information as XML
13.2.3 Drawing raster data
13.3 Summary
appendix A Installation
A.1 Anaconda
A.2 Nonbundled installations
A.2.1 Linux
A.2.2 Mac OS X
A.2.3 Windows
A.3 Environment variables
A.4 Source code and data
A.5 Development environments
appendix B References
Data used in figures
Chapter 1
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Data references
index
Symbols
Numerics
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Geoprocessing with Python-back