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

Learning Geospatial Analysis with Python - Second Edition

Book Description

An effective guide to geographic information systems and remote sensing analysis using Python 3

About This Book

  • Construct applications for GIS development by exploiting Python
  • This focuses on built-in Python modules and libraries compatible with the Python Packaging Index distribution system—no compiling of C libraries necessary
  • This practical, hands-on tutorial teaches you all about Geospatial analysis in Python

Who This Book Is For

If you are a Python developer, researcher, or analyst who wants to perform Geospatial, modeling, and GIS analysis with Python, then this book is for you. Familarity with digital mapping and analysis using Python or another scripting language for automation or crunching data manually is appreciated.

What You Will Learn

  • Automate Geospatial analysis workflows using Python
  • Code the simplest possible GIS in 60 lines of Python
  • Mold thematic maps with Python tools
  • Get hold of the various forms that geospatial data comes in
  • Produce elevation contours using Python tools
  • Create flood inundation models
  • Apply Geospatial analysis to find out about real-time data tracking and for storm chasing

In Detail

Geospatial Analysis is used in almost every field you can think of from medicine, to defense, to farming. This book will guide you gently into this exciting and complex field. It walks you through the building blocks of geospatial analysis and how to apply them to influence decision making using the latest Python software.

Learning Geospatial Analysis with Python, 2nd Edition uses the expressive and powerful Python 3 programming language to guide you through geographic information systems, remote sensing, topography, and more, while providing a framework for you to approach geospatial analysis effectively, but on your own terms. We start by giving you a little background on the field, and a survey of the techniques and technology used. We then split the field into its component specialty areas: GIS, remote sensing, elevation data, advanced modeling, and real-time data.

This book will teach you everything you need to know about, Geospatial Analysis from using a particular software package or API to using generic algorithms that can be applied. This book focuses on pure Python whenever possible to minimize compiling platform-dependent binaries, so that you don’t become bogged down in just getting ready to do analysis. This book will round out your technical library through handy recipes that will give you a good understanding of a field that supplements many a modern day human endeavors.

Style and approach

This is a practical, hands-on tutorial that teaches you all about Geospatial analysis interactively using Python.

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 code file.

Table of Contents

  1. Learning Geospatial Analysis with Python Second Edition
    1. Table of Contents
    2. Learning Geospatial Analysis with Python Second Edition
    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. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Learning Geospatial Analysis with Python
      1. Geospatial analysis and our world
        1. Beyond disasters
      2. History of geospatial analysis
      3. Geographic information systems
      4. Remote sensing
      5. Elevation data
      6. Computer-aided drafting
      7. Geospatial analysis and computer programming
        1. Object-oriented programming for geospatial analysis
      8. Importance of geospatial analysis
      9. Geographic information system concepts
        1. Thematic maps
        2. Spatial databases
        3. Spatial indexing
        4. Metadata
        5. Map projections
        6. Rendering
          1. Remote sensing concepts
        7. Images as data
        8. Remote sensing and color
      10. Common vector GIS concepts
        1. Data structures
        2. Buffer
        3. Dissolve
        4. Generalize
        5. Intersection
        6. Merge
        7. Point in polygon
        8. Union
        9. Join
        10. Geospatial rules about polygons
      11. Common raster data concepts
        1. Band math
        2. Change detection
        3. Histogram
        4. Feature extraction
        5. Supervised classification
        6. Unsupervised classification
      12. Creating the simplest possible Python GIS
        1. Getting started with Python
        2. Building SimpleGIS
          1. Step by step
      13. Summary
    9. 2. Geospatial Data
      1. An overview of common data formats
      2. Data structures
        1. Common traits
          1. Geolocation
          2. Subject information
      3. Spatial indexing
        1. Indexing algorithms
          1. Quadtree index
          2. R-tree index
        2. Grids
      4. Overviews
      5. Metadata
      6. File structure
      7. Vector data
        1. Shapefiles
        2. CAD files
        3. Tag-based and markup-based formats
        4. GeoJSON
      8. Raster data
        1. TIFF files
        2. JPEG, GIF, BMP, and PNG
        3. Compressed formats
        4. ASCII Grids
        5. World files
      9. Point cloud data
      10. Web services
      11. Summary
    10. 3. The Geospatial Technology Landscape
      1. Data access
        1. GDAL
        2. OGR
      2. Computational geometry
        1. The PROJ.4 projection library
        2. CGAL
        3. JTS
        4. GEOS
        5. PostGIS
        6. Other spatially-enabled databases
          1. Oracle spatial and graph
          2. ArcSDE
          3. Microsoft SQL Server
          4. MySQL
        7. SpatiaLite
        8. Routing
          1. Esri Network Analyst and Spatial Analyst
          2. pgRouting
      3. Desktop tools (including visualization)
        1. Quantum GIS
        2. OpenEV
        3. GRASS GIS
        4. uDig
        5. gvSIG
        6. OpenJUMP
        7. Google Earth
        8. NASA World Wind
        9. ArcGIS
      4. Metadata management
        1. GeoNetwork
        2. CatMDEdit
      5. Summary
    11. 4. Geospatial Python Toolbox
      1. Installing third-party Python modules
        1. Installing GDAL
          1. Windows
          2. Linux
          3. Mac OS X
      2. Python networking libraries for acquiring data
        1. The Python urllib module
        2. FTP
        3. ZIP and TAR files
      3. Python markup and tag-based parsers
        1. The minidom module
        2. ElementTree
          1. Building XML
        3. Well-known text (WKT)
      4. Python JSON libraries
        1. The json module
        2. The geojson module
      5. OGR
      6. PyShp
      7. dbfpy
      8. Shapely
      9. Fiona
      10. GDAL
      11. NumPy
      12. PIL
      13. PNGCanvas
      14. GeoPandas
      15. PyMySQL
      16. PyFPDF
      17. Spectral Python
      18. Summary
    12. 5. Python and Geographic Information Systems
      1. Measuring distance
        1. Pythagorean theorem
        2. Haversine formula
        3. Vincenty's formula
      2. Calculating line direction
      3. Coordinate conversion
      4. Reprojection
      5. Editing shapefiles
        1. Accessing the shapefile
        2. Reading shapefile attributes
        3. Reading shapefile geometry
        4. Changing a shapefile
          1. Adding fields
        5. Merging shapefiles
          1. Merging shapefiles with dbfpy
        6. Splitting shapefiles
          1. Subsetting spatially
      6. Performing selections
        1. Point in polygon formula
        2. Bounding Box Selections
        3. Attribute selections
      7. Creating images for visualization
      8. Dot density calculations
      9. Choropleth maps
      10. Using spreadsheets
      11. Using GPS data
      12. Geocoding
      13. Summary
    13. 6. Python and Remote Sensing
      1. Swapping image bands
      2. Creating histograms
        1. Performing a histogram stretch
      3. Clipping images
      4. Classifying images
      5. Extracting features from images
      6. Change detection
      7. Summary
    14. 7. Python and Elevation Data
      1. ASCII Grid files
        1. Reading grids
        2. Writing grids
      2. Creating a shaded relief
      3. Creating elevation contours
      4. Working with LIDAR
        1. Creating a grid from LIDAR
        2. Using PIL to visualize LIDAR
        3. Creating a triangulated irregular network
      5. Summary
    15. 8. Advanced Geospatial Python Modeling
      1. Creating a Normalized Difference Vegetative Index
        1. Setting up the framework
        2. Loading the data
        3. Rasterizing the shapefile
        4. Clipping the bands
        5. Using the NDVI formula
        6. Classifying the NDVI
          1. Additional functions
          2. Loading the NDVI
          3. Preparing the NDVI
          4. Creating classes
      2. Creating a flood inundation model
        1. The flood fill function
        2. Making a flood
      3. Creating a color hillshade
      4. Least cost path analysis
        1. Setting up the test grid
        2. The simple A* algorithm
        3. Generating the test path
        4. Viewing the test output
        5. The real-world example
          1. Loading the grid
          2. Defining the helper functions
          3. The real-world A* algorithm
          4. Generating a real-world path
      5. Routing along streets
      6. Geolocating photos
      7. Summary
    16. 9. Real-Time Data
      1. Tracking vehicles
      2. The NextBus agency list
      3. The NextBus route list
      4. NextBus vehicle locations
      5. Mapping NextBus locations
      6. Storm chasing
      7. Reports from the field
      8. Summary
    17. 10. Putting It All Together
      1. A typical GPS report
      2. Working with GPX-Reporter.py
      3. Stepping through the program
      4. The initial setup
      5. Working with utility functions
      6. Parsing the GPX
      7. Getting the bounding box
      8. Downloading map and elevation images
      9. Creating the hillshade
      10. Creating maps
      11. Measuring the elevation
      12. Measuring the distance
      13. Retrieving weather data
      14. Summary
    18. Index