Tutorial series · 5 parts

AI habitat classification with Python

Map Peak District habitats from Sentinel-2, from a transparent rule-based classifier to modern foundation-model embeddings. Along the way the series trains a gradient-boosted classifier, segments the landscape into image objects and classifies a full year of observations with temporal neural networks, assessing every map against reference data.

Level
Beginner to Advanced
Parts
5, all published
Reading time
About 109 minutes

Start with part 1: Habitat mapping with Sentinel-2 in Python: spectral index rules and an honest accuracy assessment

The parts, in order

  1. Part 1 Beginner 19 min read

    Habitat mapping with Sentinel-2 in Python: spectral index rules and an honest accuracy assessment

    Map blanket bog, heath, bracken, grassland, woodland, water and built-up land in the Peak District from 2023 Sentinel-2 seasonal composites with an eight-rule spectral index classifier, then assess it properly: a confusion matrix, user's and producer's accuracy, kappa and its caveats, block-bootstrap confidence intervals, and why a random train/test split overstates accuracy.

  2. Part 2 Intermediate 21 min read

    Habitat classification with LightGBM in Python: Sentinel-2, Sentinel-1 and terrain fusion

    Classify nine upland habitats in the Peak District with LightGBM on 77 multi-temporal features: seasonal Sentinel-2 bands and indices, Sentinel-1 VV and VH backscatter and Copernicus DEM terrain. Tune with spatial-fold cross-validation and class weights, run an S2 / S2+S1 / S2+S1+terrain ablation, explain the model with TreeSHAP and permutation importance, and compare it with a random forest and the Part 1 rules on the same test blocks.

  3. Part 3 Advanced 21 min read

    Object-based image analysis in Python: OBIA habitat classification with Sentinel-2

    Segment 2023 Sentinel-2 seasonal composites of the Peak District into image objects with scikit-image SLIC and Felzenszwalb, tune the segment size against Living England boundaries, compute per-object statistics, shape and GLCM texture with NumPy, classify the objects with LightGBM and compare OBIA with a pixel-based classifier on accuracy, salt-and-pepper noise and patch counts. Then export the habitat objects as GeoPackage polygons.

  4. Part 4 Advanced 24 min read

    Satellite image time series classification with deep learning: TempCNN and L-TAE in PyTorch on a CPU

    Classify habitats from a full year of cloudy, irregular Sentinel-2 observations with two temporal neural networks in PyTorch: a 1D convolutional TempCNN and a lightweight temporal attention encoder (L-TAE) with day-of-year positional encoding. Compare masking with gap-filling, test against a LightGBM baseline on spatial blocks, read which dates matter from attention and occlusion, and predict a wall-to-wall 10 m map on a CPU.

  5. Part 5 Advanced 24 min read

    AlphaEarth satellite embeddings in Python: few-shot habitat mapping, uncertainty and area estimates

    Use Google DeepMind's AlphaEarth Foundations satellite embeddings, a geospatial foundation model, in Python without a login. Classify nine Peak District habitats with a linear model, compare a few-shot learning curve against raw Sentinel-2 bands, map uncertainty, check calibration, simulate active learning, and estimate habitat areas with confidence intervals from a stratified random sample (Olofsson et al. 2014).

All tutorial series