Python for Geospatial Data Analysis

Book description

In spatial data science, things in closer proximity to one another likely have more in common than things that are farther apart. With this practical book, geospatial professionals, data scientists, business analysts, geographers, geologists, and others familiar with data analysis and visualization will learn the fundamentals of spatial data analysis to gain a deeper understanding of their data questions.

Author Bonny P. McClain demonstrates why detecting and quantifying patterns in geospatial data is vital. Both proprietary and open source platforms allow you to process and visualize spatial information. This book is for people familiar with data analysis or visualization who are eager to explore geospatial integration with Python.

This book helps you:

  • Understand the importance of applying spatial relationships in data science
  • Select and apply data layering of both raster and vector graphics
  • Apply location data to leverage spatial analytics
  • Design informative and accurate maps
  • Automate geographic data with Python scripts
  • Explore Python packages for additional functionality
  • Work with atypical data types such as polygons, shape files, and projections
  • Understand the graphical syntax of spatial data science to stimulate curiosity

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Why Python?
    2. How This Book Works
    3. Who Is This Book For?
    4. A Few Tips on Tooling
    5. Finding Your Way
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Online Learning
    9. How to Contact Us
    10. Acknowledgments
  2. 1. Introduction to Geospatial Analytics
    1. Democratizing Data
    2. Asking Data Questions
    3. A Conceptual Framework for Spatial Data Science
      1. Map Projections
      2. Vector Data: Places as Objects
      3. Raster Data: Understanding Spatial Relationships
    4. Evaluating and Selecting Datasets
    5. Summary
  3. 2. Essential Facilities for Spatial Analysis
    1. Exploring Spatial Data in QGIS
      1. Installing QGIS
      2. Adding Basemaps to QGIS
      3. Exploring Data Resources
    2. Visualizing Environmental Complaints in New York City
      1. Uploading Data to QGIS
      2. Setting the Project CRS
      3. Using the Query Editor to Filter Data
    3. Visualizing Population Data
      1. The QGIS Python Console
      2. Loading a Raster Layer
      3. Redlining: Mapping Inequalities
    4. Summary
  4. 3. QGIS: Exploring PyQGIS and Native Algorithms for Spatial Analytics
    1. Exploring the QGIS Workspace: Tree Cover and Inequality in San Francisco
      1. The Python Plug-in
      2. Accessing the Data
      3. Working with Layer Panels
      4. Addressing the Research Question
    2. Web Feature Service: Identifying Environmental Threats in Massachusetts
      1. Accessing the Data
      2. Discovering Attributes
      3. Working with Iterators
      4. Layer Styling
    3. Using Processing Algorithms in the Python Console
      1. Working with Algorithms
      2. Extract by Expression
      3. Buffer
      4. Extract by Location
    4. Summary
  5. 4. Geospatial Analytics in the Cloud: Google Earth Engine and Other Tools
    1. Google Earth Engine Setup
    2. Using the GEE Console and geemap
      1. Creating a Conda Environment
      2. Opening the Jupyter Notebook
      3. Installing geemap and Other Packages
    3. Navigating geemap
      1. Layers and Tools
      2. Basemaps
    4. Exploring the Landsat 9 Image Collection
    5. Working with Spectral Bands
    6. The National Land Cover Database Basemap
      1. Accessing the Data
      2. Building a Custom Legend
    7. Leafmap: An Alternative to Google Earth Engine
    8. Summary
  6. 5. OpenStreetMap: Accessing Geospatial Data with OSMnx
    1. A Conceptual Model of OpenStreetMap
      1. Tags
      2. Multidigraphs
    2. Installing OSMnx
    3. Choosing a Location
    4. Understanding Arguments and Parameters
    5. Calculating Travel Times
    6. Basic Statistical Measures in OSMnx
      1. Circuity
      2. Network Analysis: Circuity in Paris, France
      3. Betweenness Centrality
      4. Network Types
    7. Customizing Your Neighborhood Maps
      1. Geometries from Place
      2. Geometries from Address
    8. Working with QuickOSM in QGIS
    9. Summary
  7. 6. The ArcGIS Python API
    1. Setup
      1. Modules Available in the ArcGIS Python API
      2. Installing ArcGIS Pro
      3. Setting Up Your Environment
      4. Installing Packages
    2. Connecting to the ArcGIS Python API
      1. Connecting to ArcGIS Online as an Anonymous User
      2. Connecting to an ArcGIS User Account with Credentials
    3. Exploring Imagery Layers: Urban Heat Island Maps
    4. Raster Functions
    5. Exploring Image Attributes
      1. Improving Images
      2. Comparing a Location over Multiple Points in Time
      3. Filtering Layers
    6. Summary
  8. 7. GeoPandas and Spatial Statistics
    1. Installing GeoPandas
    2. Working with GeoJSON files
    3. Creating a GeoDataFrame
    4. Working with US Census Data: Los Angeles Population Density Map
      1. Accessing Tract and Population Data Through the Census API and FTP
      2. Accessing Data from the Census API in Your Browser
      3. Using Data Profiles
      4. Creating the Map
    5. Summary
  9. 8. Data Cleaning
    1. Checking for Missing Data
      1. Uploading to Colab
      2. Nulls and Non-Nulls
      3. Data Types
      4. Metadata
      5. Summary Statistics
      6. Replacing Missing Values
    2. Visualizing Data with Missingno
    3. Mapping Patterns
      1. Latitude and Longitude
      2. Shapefiles
    4. Summary
  10. 9. Exploring the Geospatial Data Abstraction Library (GDAL)
    1. Setting Up GDAL
      1. Installing Spyder
      2. Installing GDAL
    2. Working with GDAL at the Command Line
    3. Editing Your Data with GDAL
      1. The Warp Function
      2. Capturing Input Raster Bands
    4. Working with the GDAL Library in Python
      1. Getting Oriented in Spyder
      2. Exploring Your Data in Spyder
      3. Transforming Files in GDAL
      4. Using the Binmask in GDAL
      5. The Complete Script
    5. Exploring Open Source Raster Files
      1. USGS EarthExplorer
      2. Copernicus Open Access Hub
      3. Google Earth Engine
    6. Summary
  11. 10. Using Python to Measure Climate Data
    1. Example 1: Examining Climate Prediction with Precipitation Data
      1. Goals
      2. Downloading Your Data
      3. Working in Xarray
      4. Combining Your 2015 and 2021 Datasets
      5. Generating the Images
      6. More Exploration
    2. Example 2: Deforestation and Carbon Emissions in the Amazon Rain Forest Using WTSS Series
      1. Setup
      2. Creating Your Map
      3. Analysis
      4. Refinements
    3. Example 3: Modeling and Forecasting Deforestation in Guadeloupe with Forest at Risk
      1. Setup
      2. Plotting the Data
      3. Sampling the Data
      4. Correlation Plots
      5. Modeling the Probability of Deforestation with the iCAR Model
      6. The MCMC Distance Matrix
      7. Modeling Deforestation Probability with predict_raster_binomial_iCAR
      8. Carbon Emissions
      9. Analysis
    4. Summary
  12. A. Additional Resources
    1. Python Libraries for Geospatial Analysis
    2. Resources for Further Exploration
  13. Bibliography
  14. Index
  15. About the Author

Product information

  • Title: Python for Geospatial Data Analysis
  • Author(s): Bonny P. McClain
  • Release date: October 2022
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098104795