![]()
Python Geospatial Development
Table of Contents
Python Geospatial Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Geo-Spatial Development Using Python
Python
Geo-spatial development
Applications of geo-spatial development
Analyzing geo-spatial data
Visualizing geo-spatial data
Creating a geo-spatial mash-up
Recent developments
Summary
2. GIS
Core GIS concepts
Location
Distance
Units
Projections
Cylindrical projections
Conic projections
Azimuthal projections
The nature of map projections
Coordinate systems
Datums
Shapes
GIS data formats
Working with GIS data manually
Summary
3. Python Libraries for Geo-Spatial Development
Reading and writing geo-spatial data
GDAL/OGR
GDAL design
GDAL example code
OGR design
OGR example code
Documentation
Availability
Dealing with projections
pyproj
Design
Proj
Geod
Example code
Documentation
Availability
Analyzing and manipulating geo-spatial data
Shapely
Design
Example code
Documentation
Availability
Visualizing geo-spatial data
Mapnik
Design
Example code
Documentation
Availability
Summary
4. Sources of Geo-Spatial Data
Sources of geo-spatial data in vector format
OpenStreetMap
Data format
Obtaining and using OpenStreetMap data
The OpenStreetMap API
Planet.osm
Mirror sites
Working with OpenStreetMap XML data
TIGER
Data format
Obtaining and using TIGER data
Digital Chart of the World
Data format
Available layers
Obtaining and using DCW data
GSHHS
Data format
Obtaining the GSHHS database
World Borders Dataset
Data format
Obtaining the World Borders Dataset
Sources of geo-spatial data in raster format
Landsat
Data format
Obtaining Landsat imagery
GLOBE
Data format
Obtaining and using GLOBE data
National Elevation Dataset
Data format
Obtaining and using NED data
Sources of other types of geo-spatial data
GEOnet Names Server
Data format
Obtaining and using GEOnet Names Server data
GNIS
Data format
Obtaining and using GNIS data
Summary
5. Working with Geo-Spatial Data in Python
Prerequisites
Reading and writing geo-spatial data
Task: Calculate the bounding box for each country in the world
Task: Save the country bounding boxes into a Shapefile
Task: Analyze height data using a digital elevation map
Changing datums and projections
Task: Change projections to combine Shapefiles using geographic and UTM coordinates
Task: Change datums to allow older and newer TIGER data to be combined
Representing and storing geo-spatial data
Task: Calculate the border between Thailand and Myanmar
Task: Save geometries into a text file
Working with Shapely geometries
Task: Identify parks in or near urban areas
Converting and standardizing units of geometry and distance
Task: Calculate the length of the Thai-Myanmar border
Task: Find a point 132.7 kilometers west of Soshone, California
Exercises
Summary
6. GIS in the Database
Spatially-enabled databases
Spatial indexes
Open source spatially-enabled databases
MySQL
PostGIS
Installing and configuring PostGIS
Using PostGIS
Documentation
Advanced PostGIS features
SpatiaLite
Installing SpatiaLite
Mac OS X
MS Windows
Linux
Installing pysqlite
Accessing SpatiaLite from Python
Documentation
Using SpatiaLite
SpatiaLite capabilities
Commercial spatially-enabled databases
Oracle
MS SQL Server
Recommended best practices
Use the database to keep track of spatial references
Use the appropriate spatial reference for your data
Option 1: Use a database that supports geographies
Option 2: Transform features as required
Option 3: Transform features from the outset
When to use unprojected coordinates
Avoid on-the-fly transformations within a query
Don't create geometries within a query
Use spatial indexes appropriately
Know the limits of your database's query optimizer
MySQL
PostGIS
SpatiaLite
Working with geo-spatial databases using Python
Prerequisites
Working with MySQL
Working with PostGIS
Working with SpatiaLite
Speed comparisons
Summary
7. Working with Spatial Data
About DISTAL
Designing and building the database
Downloading the data
World Borders Dataset
GSHHS
Geonames
GEOnet Names Server
Importing the data
World Borders Dataset
GSHHS
US placename data
Worldwide placename data
Implementing the DISTAL application
The "Select Country" script
The "Select Area" script
Calculating the bounding box
Calculating the map's dimensions
Setting up the datasource
MySQL
PostGIS
SpatiaLite
Rendering the map image
The "Show Results" script
Identifying the clicked-on point
Identifying features by distance
Calculating distances manually
Using angular distances
Using projected coordinates
A hybrid approach
Spatial joins
Identifying points by true distance
Displaying the results
Application review and improvements
Usability
Quality
Placename issues
Lat/Long coordinate problems
Performance
Finding the problem
Improving performance
Calculating the tiled shorelines
Using the tiled shorelines
Analyzing the performance improvement
Further performance improvements
Scalability
Summary
8. Using Python and Mapnik to Generate Maps
Introducing Mapnik
Creating an example map
Mapnik in depth
Data sources
Shapefile
PostGIS
GDAL
OGR
SQLite
OSM
PointDatasource
Rules, filters, and styles
Filters
Scale denominators
"Else" rules
Symbolizers
Drawing lines
LineSymbolizer
Line color
Line width
Opacity
Line caps
Line joins
Dashed and dotted lines
LinePatternSymbolizer
Drawing polygons
PolygonSymbolizer
Fill color
Opacity
Gamma correction
PolygonPatternSymbolizer
Drawing labels
TextSymbolizer
Specifying the text to be displayed
Selecting a suitable font
Drawing semi-transparent text
Controlling text placem...