TL;DR
TorchGeo bridges the gap between geospatial data and deep learning by providing a PyTorch-native ecosystem specifically designed for Earth Observation (EO). This paper introduces a hands-on tutorial and an end-to-end case study demonstrating how to seamlessly handle complex coordinate reference systems, perform lazy on-demand data sampling, and train a multispectral water segmentation model.
What Problem Does This Paper Address?
Applying machine learning to satellite imagery is fundamentally different from standard computer vision—it is not simply "computer vision with larger images."
In typical Earth Observation pipelines, data is delivered as massive, multi-band, georeferenced scenes. Labels might arrive separately as raster masks or vector geometries, often using entirely different coordinate reference systems (CRSs) and spatial resolutions. Standard deep learning frameworks lack the tools to handle this spatial metadata natively. As a result, researchers often spend significant time on fragile, storage-heavy preprocessing pipelines (like manual "pre-tiling" and re-projecting) which can inadvertently introduce spatial data leakage and break reproducibility.
Methods
The paper highlights TorchGeo, a PyTorch domain library (analogous to torchvision) that introduces several key abstractions to simplify EO workflows:
- Composable Datasets: TorchGeo introduces set-like operators (
&for intersection,|for union) to combine datasets. For example,landsat & cdlautomatically restricts sampling to regions where both imagery and labels overlap. Crucially, this composition is lazy—re-projection and alignment happen on-demand during windowed reads. - Geographic Samplers: Instead of randomly sampling indices from an array, TorchGeo uses spatial samplers.
RandomGeoSamplerextracts training chips directly from geographic space (helping mitigate spatial autocorrelation), whileGridGeoSamplermanages overlapping patches for gridded inference. - Multispectral Architecture Adaptation: Standard computer vision models are built for 3-channel RGB images. The tutorial demonstrates how to modify a standard
torchvisionarchitecture (DeepLabV3 with a ResNet-50 backbone) by re-initializing the first convolutional layer to accept $C > 3$ channels. In this case study, the model ingests 6 spectral bands plus 3 appended spectral indices (NDVI and two variants of NDWI).
Datasets
The tutorial utilizes the Earth Surface Water dataset, which contains globally distributed Sentinel-2 multispectral image patches and corresponding binary water masks.
For the real-world inference demonstration, the authors use a complete Sentinel-2 scene over Rio de Janeiro, Brazil, sourced from the Microsoft Planetary Computer.
Key Insights and Ideas
- Bypassing the "Pre-Tiling" Bottleneck: By utilizing lazy loading via
RandomGeoSampler, TorchGeo performs windowed reads of only the required pixels for each batch. This eliminates the need to generate and store massive pre-cut image tiles on disk. - Smart Feature Engineering with Normalization: The authors present a clever template for multispectral preprocessing: they compute dataset-specific mean and standard deviation statistics for the raw sensor bands, append physical spectral indices (like NDVI), and then pad the normalization statistics. This ensures that normalization is only applied to the raw bands, leaving the physically meaningful indices unaltered for the model.
Key Results
The tutorial walks through a compact training loop that yields strong baseline performance:
- Quantitative Performance: Trained from scratch for just 10 epochs (130 samples per epoch) using an AdamW optimizer, the DeepLabV3 model achieved an overall accuracy of 0.977 and an Intersection over Union (IoU) of 0.824 on the validation set.
- End-to-End Deployment: The pipeline successfully runs gridded inference over the Rio de Janeiro scene and exports the final predictions back into a pixel-aligned GeoTIFF, making the output immediately ready for downstream GIS analysis.
Limitations and Future Work
Because this paper is framed as a tutorial workshop submission, it focuses on API demonstration rather than pushing the boundaries of state-of-the-art model architectures. The authors note that looking purely at validation metrics can mask real-world limitations. They encourage users to qualitatively explore the limits of the generated GeoTIFFs—such as evaluating how sharp predictions are along complex coastlines, how the model behaves under challenging atmospheric conditions, and determining the minimum size of detectable water bodies.
Summary updated