Tutorial series · 3 parts

Geospatial Python essentials

The steps nearly every geospatial Python project depends on: getting coordinate reference systems right, joining datasets by location in GeoPandas, and converting between raster and vector data.

Level
Beginner to Intermediate
Parts
3, all published
Reading time
About 39 minutes

Start with part 1: Coordinate reference systems in Python: EPSG codes, pyproj transforms and reprojecting vectors and rasters

The parts, in order

  1. Part 1 Beginner 13 min read

    Coordinate reference systems in Python: EPSG codes, pyproj transforms and reprojecting vectors and rasters

    A practical guide to coordinate reference systems in Python with pyproj, GeoPandas and rasterio, tested on real Greater Manchester data. Covers EPSG codes, WGS 84 vs British National Grid (EPSG:27700), the always_xy axis-order trap, OSTN15 vs Helmert datum shifts checked against 13,187 NaPTAN bus stops, measured area and distance errors in the wrong CRS, and reprojecting a GeoDataFrame and a Copernicus DEM raster.

  2. Part 2 Beginner 12 min read

    Spatial joins in GeoPandas: sjoin, predicates, sjoin_nearest and point in polygon

    A practical guide to spatial joins in GeoPandas with real Greater Manchester data: 13,187 NaPTAN bus stops, 1,386 OpenStreetMap schools, 215 ONS wards and 1,702 LSOAs. Covers point in polygon with sjoin, predicates, counts per polygon, how='left'/'inner'/'right', sjoin_nearest with max_distance, clip and overlay, and a timing comparison of a naive loop against the spatial index.

  3. Part 3 Intermediate 14 min read

    Raster to vector in Python: polygonize with rasterio, rasterize boundaries and convert a GeoTIFF to a Cloud Optimized GeoTIFF

    Convert raster to vector in Python with rasterio.features.shapes on 10 m ESA WorldCover for Greater Manchester: polygonize water and built-up land, fix invalid polygons, simplify without gaps, rasterize ONS district boundaries for land-cover shares, then write and validate a Cloud Optimized GeoTIFF with rio-cogeo and measure HTTP range reads.

All tutorial series