Build your first interactive map and build location-aware applications using cutting-edge examples in PythonAbout This Book- Learn the full geo-processing workflow using Python with open source packages- Create press-quality styled maps and data visualization with high-level and reusable code- Process massive datasets efficiently using parallel processingWho This Book Is ForGeospatial Development By Example with Python is intended for beginners or advanced developers in Python who want to work with geographic data. The book is suitable for professional developers who are new to geospatial development, for hobbyists, or for data scientists who want to move into some simple development.What You Will Learn- Prepare a development environment with all the tools needed for geo-processing with Python- Import point data and structure an application using Python's resources- Combine point data from multiple sources, creating intuitive and functional representations of geographic objects- Filter data by coordinates or attributes easily using pure Python- Make press-quality and replicable maps from any data- Download, transform, and use remote sensing data in your maps- Make calculations to extract information from raster data and show the results on beautiful maps- Handle massive amounts of data with advanced processing techniques- Process huge satellite images in an efficient way- Optimize geo-processing times with parallel processingIn DetailFrom Python programming good practices to the advanced use of analysis packages, this book teaches you how to write applications that will perform complex geoprocessing tasks that can be replicated and reused.Much more than simple scripts, you will write functions to import data, create Python classes that represent your features, and learn how to combine and filter them.With pluggable mechanisms, you will learn how to visualize data and the results of analysis in beautiful maps that can be batch-generated and embedded into documents or web pages.Finally, you will learn how to consume and process an enormous amount of data very efficiently by using advanced tools and modern computers' parallel processing capabilities.Style and approachThis easy-to-follow book is filled with hands-on examples that illustrate the construction of three sample applications of how to write reusable and interconnected Python code for geo-processing.
Author(s): Pablo Carreira
Year: 2016
Language: English
Pages: 340
Geospatial Development By Example with Python
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
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Preparing the Work Environment
Installing Python
Windows
Ubuntu Linux
Python packages and package manager
The repository of Python packages for Windows
Installing packages and required software
OpenCV
Windows
Ubuntu Linux
Installing NumPy
Windows
Ubuntu Linux
Installing GDAL and OGR
Windows
Ubuntu Linux
Installing Mapnik
Windows
Ubuntu Linux
Installing Shapely
Windows
Ubuntu Linux
Installing other packages directly from pip
Windows
Ubuntu Linux
Installing an IDE
Windows
Linux
Creating the book project
Programming and running your first example
Transforming the coordinate system and calculating the area of all countries
Sort the countries by area size
Summary
2. The Geocaching App
Building the basic application structure
Creating the application tree structure
Functions and methods
Documenting your code
Creating the application entry point
Downloading geocaching data
Geocaching data sources
Fetching information from a REST API
Downloading data from a URL
Downloading data manually
Opening the file and getting its contents
Preparing the content for analysis
Combining functions into an application
Setting your current location
Finding the closest point
Summary
3. Combining Multiple Data Sources
Representing geographic data
Representing geometries
Making data homogeneous
The concept of abstraction
Abstracting the geocache point
Abstracting geocaching data
Importing geocaching data
Reading GPX attributes
Returning the homogeneous data
Converting the data into Geocache objects
Merging multiple sources of data
Integrating new functionality into the application
Summary
4. Improving the App Search Capabilities
Working with polygons
Knowing well-known text
Using Shapely to handle geometries
Importing polygons
Getting the attributes' values
Importing lines
Converting the spatial reference system and units
Geometry relationships
Touches
Crosses
Contains
Within
Equals or almost equals
Intersects
Disjoint
Filtering by attributes and relations
Filtering by multiple attributes
Chaining filters
Integrating with the app
Summary
5. Making Maps
Knowing Mapnik
Making a map with pure Python
Making a map with a style sheet
Creating utility functions to generate maps
Changing the data source at runtime
Automatically previewing the map
Styling maps
Map style
Polygon style
Line styles
Text styles
Adding layers to the map
Point styles
Using Python objects as a source of data
Exporting geo objects
Creating the Map Maker app
Using PythonDatasource
Using the app with filtering
Summary
6. Working with Remote Sensing Images
Understanding how images are represented
Opening images with OpenCV
Knowing numerical types
Processing remote sensing images and data
Mosaicking images
Adjusting the values of the images
Cropping an image
Creating a shaded relief image
Building an image processing pipeline
Creating a RasterData class
Summary
7. Extract Information from Raster Data
Getting the basic statistics
Preparing the data
Printing simple information
Formatting the output information
Calculating quartiles, histograms, and other statistics
Making statistics a lazy property
Creating color classified images
Choosing the right colors for a map
Blending images
Showing statistics with colors
Using the histogram to colorize the image
Summary
8. Data Miner App
Measuring execution time
Code profiling
Storing information on a database
Creating an Object Relational Mapping
Preparing the environment
Changing our models
Customizing a manager
Generating the tables and importing data
Filtering the data
Importing massive amount of data
Optimizing database inserts
Optimizing data parsing
Importing OpenStreetMap points of interest
Removing the test data
Populating the database with real data
Searching for data and crossing information
Filtering using boundaries
Summary
9. Processing Big Images
Working with satellite images
Getting Landsat 8 images
Memory and images
Processing images in chunks
Using GDAL to open images
Iterating through the whole image
Creating image compositions
True color compositions
Processing specific regions
False color compositions
Summary
10. Parallel Processing
Multiprocessing basics
Block iteration
Improving the image resolution
Image resampling
Pan sharpening
Summary
Index