Intermediate Geospatial Analysis in Python
About this course
You can already load a shapefile, reproject it and draw a map. This course covers the analysis that comes after that: turning messy location data into something you can measure, modelling infrastructure as a network, and deciding whether a spatial pattern is genuine or noise.
Day One focuses on getting data into a state you can analyse, and doing it repeatably. Geocoding shows why repeatability matters. Geocoding tens of thousands of addresses through a service that allows one request a second takes the better part of a day, so most of that topic is about running long, unreliable jobs. This means caching results to disk, tolerating failures, reporting progress and saving as you go. The rest of the day moves between representations. You vectorise raster data with Rasterio and rasterise vector features back the other way, reduce a polygon to a centreline so you can measure its length, and use scikit-image to find and count features in drone imagery.
Day Two focuses on spatial statistics, and whether a pattern on the map means anything. Nearby observations are usually more alike than distant ones, so clusters on a map are common. Some of them are real patterns and some are not. With PySAL you build spatial weights, measure global autocorrelation, and then localise it to find the hotspots, coldspots and individual anomalies worth investigating. The same test is also run against random noise of the same shape, which is the quickest way to see what a significant result looks like. You then predict continuous surfaces from scattered observations with SciPy and scikit-learn. This includes why a regressor that assumes independent samples is the wrong tool for spatially dependent data.
The last part of the course deals with scale. When a raster no longer fits in memory, you chunk it with Dask and keep working. When a scatter plot has more points than the screen has pixels and comes out as a solid block of ink, you aggregate it with Datashader instead. Worked examples use real datasets throughout, and you write code in every section.
Bring your own datasets and we will work through them with you.
Who this course is for
GIS analysts, scientists, engineers, surveyors and data analysts who already work with spatial data in Python and now need it to answer questions rather than only to draw maps. The course suits people who can load a shapefile and a raster and plot them, and who are stuck at the next step: deciding whether a cluster on the map is real, measuring capacity across a network, or processing imagery that no longer fits in memory.
This course also suits teams in environment and water agencies, transport, mining and resources, emergency services, local government and health, where spatial analysis is repeated on a schedule and the datasets keep growing. Many participants have completed Python for Geospatial Analysis and want the analytical half of the subject.
Prerequisites
Our Python for Geospatial Analysis course, or equivalent experience.
You should already be comfortable reading vector data into GeoPandas, working with rasters in xarray or Rasterio, and handling coordinate reference systems and reprojection. We revise these on the first morning rather than teaching them from scratch. No background in graph theory, spatial statistics or parallel computing is assumed, and you do not need any machine learning experience.
What you will learn
- Geocode large batches of messy address and place-name data with GeoPy, including the rate limiting, caching and checkpointing a long job needs
- Convert between raster and vector representations with Rasterio and scikit-image, including reducing a shape to its centreline
- Detect and count features in imagery with scikit-image, and check the result against ground-truthed data
- Model infrastructure as a network in NetworkX and answer capacity and shortest-path questions
- Test whether a spatial pattern is genuine or an artefact, and locate hotspots and coldspots, using PySAL
- Predict a continuous surface from scattered observations with SciPy and scikit-learn, and render datasets too large to plot point by point
Syllabus
Day 1: Automating geospatial processes
- Revision of GeoPandas, projections and raster handling
- Geocoding at scale with GeoPy: rate limits, caching and fuzzy place names
- Converting between raster and vector representations
- Skeletonisation: reducing a polygon to a centreline
- Image analysis with scikit-image, from filters to labelled regions
- Network analysis with NetworkX: flow, capacity and shortest paths
- Automating an analysis pipeline end to end
Day 2: Extended analysis of spatial data
- Spatial weights and connectivity with PySAL
- Spatial dependence: Moran's I, Geary's C and the Moran scatterplot
- Local indicators of spatial association: hotspots, coldspots and anomalies
- Spatial interpolation and regression with SciPy and scikit-learn
- Large-scale raster analysis with Dask and xarray
- Rendering very large datasets with Datashader