You are previewing Geospatial Development By Example with Python.
O'Reilly logo
Geospatial Development By Example with Python

Book Description

Build your first interactive map and build location-aware applications using cutting-edge examples in Python

About 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 processing

  • Who This Book Is For

    Geospatial 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 processing

  • In Detail

    From 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 approach

    This 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.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Geospatial Development By Example with Python
      1. Table of Contents
      2. Geospatial Development By Example with Python
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Preparing the Work Environment
        1. Installing Python
          1. Windows
          2. Ubuntu Linux
        2. Python packages and package manager
          1. The repository of Python packages for Windows
        3. Installing packages and required software
          1. OpenCV
          2. Windows
          3. Ubuntu Linux
        4. Installing NumPy
          1. Windows
          2. Ubuntu Linux
        5. Installing GDAL and OGR
          1. Windows
          2. Ubuntu Linux
        6. Installing Mapnik
          1. Windows
          2. Ubuntu Linux
        7. Installing Shapely
          1. Windows
          2. Ubuntu Linux
        8. Installing other packages directly from pip
          1. Windows
          2. Ubuntu Linux
        9. Installing an IDE
          1. Windows
          2. Linux
        10. Creating the book project
        11. Programming and running your first example
        12. Transforming the coordinate system and calculating the area of all countries
        13. Sort the countries by area size
        14. Summary
      9. 2. The Geocaching App
        1. Building the basic application structure
          1. Creating the application tree structure
          2. Functions and methods
          3. Documenting your code
          4. Creating the application entry point
        2. Downloading geocaching data
          1. Geocaching data sources
          2. Fetching information from a REST API
          3. Downloading data from a URL
          4. Downloading data manually
        3. Opening the file and getting its contents
          1. Preparing the content for analysis
        4. Combining functions into an application
        5. Setting your current location
        6. Finding the closest point
        7. Summary
      10. 3. Combining Multiple Data Sources
        1. Representing geographic data
          1. Representing geometries
        2. Making data homogeneous
          1. The concept of abstraction
          2. Abstracting the geocache point
          3. Abstracting geocaching data
        3. Importing geocaching data
          1. Reading GPX attributes
          2. Returning the homogeneous data
          3. Converting the data into Geocache objects
          4. Merging multiple sources of data
        4. Integrating new functionality into the application
        5. Summary
      11. 4. Improving the App Search Capabilities
        1. Working with polygons
          1. Knowing well-known text
        2. Using Shapely to handle geometries
        3. Importing polygons
        4. Getting the attributes' values
        5. Importing lines
        6. Converting the spatial reference system and units
        7. Geometry relationships
          1. Touches
          2. Crosses
          3. Contains
          4. Within
          5. Equals or almost equals
          6. Intersects
          7. Disjoint
        8. Filtering by attributes and relations
        9. Filtering by multiple attributes
          1. Chaining filters
        10. Integrating with the app
        11. Summary
      12. 5. Making Maps
        1. Knowing Mapnik
          1. Making a map with pure Python
          2. Making a map with a style sheet
        2. Creating utility functions to generate maps
          1. Changing the data source at runtime
          2. Automatically previewing the map
        3. Styling maps
          1. Map style
          2. Polygon style
          3. Line styles
          4. Text styles
          5. Adding layers to the map
          6. Point styles
        4. Using Python objects as a source of data
        5. Exporting geo objects
        6. Creating the Map Maker app
          1. Using PythonDatasource
          2. Using the app with filtering
        7. Summary
      13. 6. Working with Remote Sensing Images
        1. Understanding how images are represented
          1. Opening images with OpenCV
          2. Knowing numerical types
        2. Processing remote sensing images and data
          1. Mosaicking images
          2. Adjusting the values of the images
          3. Cropping an image
          4. Creating a shaded relief image
        3. Building an image processing pipeline
          1. Creating a RasterData class
        4. Summary
      14. 7. Extract Information from Raster Data
        1. Getting the basic statistics
          1. Preparing the data
          2. Printing simple information
          3. Formatting the output information
          4. Calculating quartiles, histograms, and other statistics
          5. Making statistics a lazy property
        2. Creating color classified images
          1. Choosing the right colors for a map
        3. Blending images
        4. Showing statistics with colors
          1. Using the histogram to colorize the image
        5. Summary
      15. 8. Data Miner App
        1. Measuring execution time
        2. Code profiling
        3. Storing information on a database
          1. Creating an Object Relational Mapping
            1. Preparing the environment
            2. Changing our models
            3. Customizing a manager
          2. Generating the tables and importing data
          3. Filtering the data
        4. Importing massive amount of data
          1. Optimizing database inserts
          2. Optimizing data parsing
          3. Importing OpenStreetMap points of interest
          4. Removing the test data
          5. Populating the database with real data
        5. Searching for data and crossing information
          1. Filtering using boundaries
        6. Summary
      16. 9. Processing Big Images
        1. Working with satellite images
          1. Getting Landsat 8 images
        2. Memory and images
        3. Processing images in chunks
          1. Using GDAL to open images
          2. Iterating through the whole image
        4. Creating image compositions
          1. True color compositions
          2. Processing specific regions
          3. False color compositions
        5. Summary
      17. 10. Parallel Processing
        1. Multiprocessing basics
        2. Block iteration
        3. Improving the image resolution
          1. Image resampling
          2. Pan sharpening
        4. Summary
      18. Index