TorchGeo supplies datasets, samplers, transforms, and pretrained models for satellite and aerial imagery in PyTorch. It targets both ML practitioners and remote sensing specialists.
Overview
TorchGeo is a domain library for PyTorch, positioned similarly to torchvision but focused on geospatial data. It bundles datasets, geographic samplers, transforms, model weights, and training helpers so deep learning workflows can use earth observation imagery without reimplementing geo-specific plumbing.
Geospatial datasets carry coordinate reference systems, bounds, and resolution metadata. The library can align mismatched CRS and resolutions, compose union and intersection dataset combinations with operators, and sample patches from large rasters via dedicated samplers. Benchmark datasets cover classification, regression, semantic and instance segmentation, object detection, and change detection, returning tensor dictionaries compatible with standard PyTorch data loaders.
Pretrained weights support multispectral sensors beyond RGB, following torchvision's multi-weight API. Checkpoints documented on the project site include models pretrained on Sentinel-2 and related remote sensing corpora. Lightning datamodules provide train-validation-test splits and tasks for common geo ML problems, and a LightningCLI path supports YAML-driven training configuration.
Installation is via pip or uv; the project is stewarded by the independent TorchGeo organization as an OSGeo project, with related efforts such as TorchGeo-Bench and TerraTorch mentioned on the website.
Key features
- CRS-aware geospatial datasets
- Geographic random and grid samplers
- Dataset union and intersection
- Multispectral pretrained weights
- Lightning datamodules and tasks
- Automatic dataset download and checksum
- PyTorch and Lightning integration
- 100+ remote sensing datasets
Use cases
- Land-cover classification from satellites
- Geospatial semantic segmentation
- Object detection in aerial imagery
- Change detection workflows
- Transfer learning on multispectral bands