O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Python Geospatial Analysis Essentials

Book Description

Process, analyze, and display geospatial data using Python libraries and related tools

In Detail

Python is a highly expressive language that makes it easy to write sophisticated programs. Combining high-quality geospatial data with Python geospatial libraries will give you a powerful toolkit for solving a range of geospatial programming tasks.

The book begins with an introduction to geospatial analysis and programming and explains the ideas behind geospatial data. You will explore Python libraries for building your own geospatial applications. You will learn to create a geospatial database for your application using PostGIS and the psycopg2 library, and see how the Mapnik library can be used to create attractive and useful maps.

Finally, you will learn to use the Shapely and NetworkX libraries to create, analyze, and manipulate complex geometric objects, before implementing a system to match GPS recordings against a database of roads to produce a heatmap of the most frequently used roads.

What You Will Learn

  • Understand the key geospatial concepts and techniques needed to analyze and work with geospatial data
  • Learn how to read and write geospatial data from within your Python code
  • Use PostGIS to store spatial data and perform spatial queries
  • Use Python libraries to analyze and manipulate geospatial data
  • Generate maps based on your spatial data
  • Implement complete geospatial analysis systems using Python
  • Use the Shapely and NetworkX libraries to solve problems such as distance-area calculations, finding the shortest path between two points, buffering polygons, and much more

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 http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Python Geospatial Analysis Essentials
    1. Table of Contents
    2. Python Geospatial Analysis Essentials
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      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. Errata
        3. Piracy
        4. Questions
    8. 1. Geospatial Analysis and Techniques
      1. About geospatial analysis
      2. Understanding geospatial data
      3. Setting up your Python installation
        1. Installing GDAL
        2. Installing Shapely
      4. Obtaining some geospatial data
      5. Unlocking the shapefile
      6. Analyzing the data
      7. A program to identify neighboring countries
      8. Summary
    9. 2. Geospatial Data
      1. Geospatial data quality
      2. Types of geospatial data
        1. Shapefiles
        2. Well-known text
        3. Well-known binary
        4. Spatial databases
        5. Geospatial microformats
          1. GeoJSON
          2. GML
        6. Digital elevation models
        7. Raster basemaps
        8. Multiband raster files
      3. Sources of freely available geospatial data
        1. Natural Earth Data
        2. OpenStreetMap
        3. US Census Bureau
        4. World Borders Dataset
        5. GLOBE
        6. National Elevation Dataset
      4. Reading and writing geospatial data using Python
        1. Reading vector data
        2. Writing vector data
        3. Reading raster data
        4. Writing raster data
      5. Dealing with spatial reference systems
        1. WGS84
        2. Universal Transverse Mercator
        3. Describing spatial reference systems
        4. Transforming coordinates
        5. Calculating lengths and areas
      6. Geospatial data errors and how to fix them
        1. Points
        2. LineStrings
        3. Linear Rings
        4. Polygons
        5. MultiPolygons
        6. Fixing invalid geometries
      7. Summary
    10. 3. Spatial Databases
      1. Spatial database concepts
      2. Installing a spatial database
        1. Installing PostgreSQL
        2. Installing PostGIS
        3. Installing psycopg2
      3. Accessing PostGIS from Python
      4. Setting up a spatial database
      5. Importing spatial data
      6. Querying spatial data
      7. Manipulating spatial data
      8. Exporting spatial data
      9. Summary
    11. 4. Creating Maps
      1. Introducing Mapnik
        1. Installing Mapnik
        2. A taste of Mapnik
        3. Building a map
        4. Styling a map
      2. Learning Mapnik
        1. Datasources
        2. Symbolizers
          1. PointSymbolizer
          2. LineSymbolizer
          3. PolygonSymbolizer
          4. TextSymbolizer
          5. RasterSymbolizer
        3. Map rendering
      3. A working example
      4. Next steps
      5. Summary
    12. 5. Analyzing Geospatial Data
      1. Libraries for spatial analysis
        1. PyProj
        2. NetworkX
      2. Spatial analysis recipes
        1. Calculating and comparing coordinates
        2. Calculating lengths
        3. Calculating areas
        4. Calculating shortest paths
      3. Summary
    13. 6. Building a Complete Geospatial Analysis System
      1. Matching GPS data against a map
      2. An overview of the GPS Heatmap system
      3. Obtaining the necessary data
        1. Obtaining GPS data
        2. Downloading the road data
      4. Implementing the GPS Heatmap system
        1. Initializing the database
        2. Importing the road data
        3. Splitting the road data into segments
        4. Constructing a network of directed road segments
        5. Implementing the map matching algorithm
        6. Generating the GPS heatmap
      5. Further improvements
      6. Summary
    14. Index