This is a tutorial style book that will teach usage of Python tools for GIS using simple practical examples and then show you how to build a complete mapping application from scratch. The book assumes basic knowledge of Python. No knowledge of Open Source GIS is required. This book is useful for Python developers who want to get up to speed with Open Source GIS in order to build GIS applications or integrate Geo-Spatial features into their applications.
Author(s): Erik Westra
Year: 2010
Cover
Copyright
Credits
About the Author
About the Reviewers
Table of Contents
Preface
Chapter 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
Chapter 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
Chapter 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
Chapter 4:
Sources of Geo-Spatial Data
Sources of geo-spatial data in vector format
OpenStreetMap
Data format
Obtaining and using OpenStreetMap 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
Chapter 5:
XWorking 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
Chapter 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
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
Chapter 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 data source
Rendering the map image
The "Show Results" script
Identifying the clicked-on point
Identifying features by 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
Chapter 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
Drawing polygons
Drawing labels
Drawing points
Drawing raster images
Using colors
Maps and layers
Map attributes and methods
Layer attributes and methods
Map rendering
MapGenerator revisited
The MapGenerator's interface
Creating the main map layer
Displaying points on the map
Rendering the map
What the map generator teaches us
Map definition files
Summary
Chapter 9:
Web Frameworks for Python Geo-Spatial Development
Web application concepts
Web application architecture
A bare-bones approach
Web application stacks
Web application frameworks
Web services
Map rendering
Tile caching
Web servers
User interface libraries
The "slippy map" stack
The geo-spatial web application stack
Protocols
The Web Map Service (WMS) protocol
WMS-C
The Web Feature Service (WFS) protocol
The TMS (Tile Map Service) protocol
Tools
Tile caching
TileCache
mod_tile
TileLite
User interface libraries
OpenLayers
Mapiator
Web application frameworks
GeoDjango
MapFish
TurboGears
Summary
Chapter 10:
Putting it All Together: A Complete Mapping Application
About the ShapeEditor
Designing the application
Importing a Shapefile
Selecting a feature
Editing a feature
Exporting a Shapefile
Prerequisites
The structure of a Django application
Models
Views
Templates
Setting up the database
Setting up the GeoDjango project
Setting up the ShapeEditor application
Defining the data models
Shapefile
Attribute
Feature
AttributeValue
The models.py file
Playing with the admin system
Summary
Chapter 11:
ShapeEditor: Implementing List View, Import, and Export
Implementing the "List Shapefiles" view
Importing Shapefiles
The "import shapefile" form
Extracting the uploaded Shapefile
Importing the Shapefile's contents
Open the Shapefile
Add the Shapefile object to the database
Define the Shapefile's attributes
Store the Shapefile's features
Store the Shapefile's attributes
Cleaning up
Exporting Shapefiles
Define the OGR Shapefile
Saving the features into the Shapefile
Saving the attributes into the Shapefile
Compressing the Shapefile
Deleting temporary files
Returning the ZIP archive to the user
Summary
Chapter 12:
ShapeEditor: Selecting and Editing Features
Selecting a feature to edit
Implementing the Tile Map Server
Setting up the base map
Tile rendering
Using OpenLayers to display the map
Intercepting mouse clicks
Implementing the "find feature" view
Editing features
Adding features
Deleting features
Deleting Shapefiles
Using ShapeEditor
Further improvements and enhancements
Summary
Index