NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TorchGeo: deep learning with geospatial data

Adam J Stewart, Caleb Robinson, Isaac A Corley, Anthony Ortiz, Juan M Lavista Ferres, Arindam Banerjee

TL;DR

TorchGeo is an open-source Python library that seamlessly integrates geospatial and Earth observation data into the PyTorch ecosystem. It provides geospatial data loaders, composable dataset operations (unions and intersections), specialized spatial samplers, and multispectral models. By handling spatial reference systems and resolution differences on-the-fly, it removes the need for tedious GIS preprocessing pipelines while delivering competitive, reproducible baselines.

What Problem Does This Paper Address?

Deep learning has revolutionized computer vision, but Earth observation (EO) has lagged behind in ease of model development. Standard vision libraries (like torchvision and PIL) are hard-coded for three-channel RGB images and integer-indexed datasets.

Remotely sensed data breaks nearly all standard vision assumptions:

  • Variable spectral bands: Satellite sensors capture far beyond RGB—Landsat 8 collects 11 bands, Sentinel-2 captures 12, and hyperspectral sensors capture hundreds.
  • Heterogeneous metadata: Different sensors produce imagery with different coordinate reference systems (CRSs), pixel resolutions (from 7 mm/px drone imagery to 4 km/px satellite feeds), and spatial extents.
  • Complex alignment: Combining imagery with label masks or fusing multi-sensor imagery traditionally requires external GIS software (such as GDAL, QGIS, or ArcGIS) to reproject, resample, and crop raster files before training, inflating disk usage and creating high engineering barriers for ML researchers.

Methods

TorchGeo bridges this gap through several modular abstractions:

  • Spatially Indexed GeoDatasets: Instead of integer indexing (dataset[i]), geospatial datasets are indexed using spatio-temporal bounding boxes.
  • Declarative Dataset Composition: Users can combine datasets using intuitive operators:
  • Intersection (&): Aligns overlapping layers (e.g., pairing a Landsat imagery raster with a Cropland Data Layer label mask).
  • Union (|): Combines multi-sensor or contiguous spatial coverages (e.g., merging Landsat 7 and Landsat 8 scenes).
  • On-the-Fly Warping and Resampling: Reprojection, cropping, and resampling happen transparently inside the PyTorch data-loading pipeline, avoiding duplicate preprocessed datasets on disk.
  • Geospatial Samplers: Dedicated samplers query spatial bounds rather than sample indices, including:
  • RandomGeoSampler (uniform random spatial windows),
  • RandomBatchGeoSampler (batches sampled from the same scene to leverage caching),
  • GridGeoSampler (regular grid traversal, ideal for inference).
  • Multispectral Models & Augmentations: Support for variable input channels (e.g., adapting ImageNet weights by randomly initializing non-RGB first-layer kernels) and integration with Kornia for multichannel data augmentations.

Datasets

TorchGeo introduces dataloaders for over 24 benchmark datasets across tasks like scene classification, semantic segmentation, instance segmentation, and change detection.

The paper evaluates performance across several benchmarks:

  • Data loading: A 151 GB benchmark of 114 Landsat 8 scenes paired with the 2019 USDA Cropland Data Layer (CDL).
  • Benchmarking & Generalization: So2Sat-LCZ42 (local climate zone classification), LandCover.ai (aerial semantic segmentation), Chesapeake Land Cover (NAIP-based 6-class land cover across 6 US states), RESISC45, EuroSAT, UC Merced, and ETCI 2021 Flood Detection.

Key Insights and Ideas

  • LRU Caching is Crucial for Geo-Sampling: Sampling patches randomly across disparate scenes is I/O-heavy. Sampling sequential batches from within single scenes (RandomBatchGeoSampler) or following a grid (GridGeoSampler) dramatically speeds up data loading by exploiting GDAL’s least recently used (LRU) cache.
  • ImageNet Weights Act as Spatial Regularizers: When testing models on the exact region where they were trained (in-domain), ImageNet-initialized backbones perform similarly to randomly initialized ones. However, on out-of-domain geographic regions, ImageNet pre-training provides massive generalization advantages.
  • Multispectral Bands Matter for Challenging Targets: Utilizing all 12 Sentinel-2 bands rather than just RGB yielded a 4–14% absolute accuracy improvement on complex tasks like So2Sat urban climate zone classification.

Key Results

  • Competitive Baselines: Across 7 benchmark datasets, standard TorchGeo models matched or approached previous specialized state-of-the-art results without complex architecture tuning:
  • EuroSAT: 97.86% (MSI) and 98.11% (RGB) top-1 accuracy using a ResNet-50.
  • LandCover.ai: 84.81% mIoU with a standard U-Net (ResNet-50 encoder), within 0.75% of a tuned DeepLabv3+ pre-trained on Cityscapes (85.56%).
  • So2Sat: 63.99% accuracy using all Sentinel-2 bands, outperforming previous in-domain pre-training baselines (63.25%).
  • Geographic Generalization: On Chesapeake Land Cover, models trained on Delaware were evaluated on unseen states. ImageNet-initialized models outperformed scratch-trained models everywhere out-of-domain:
  • In Delaware (in-domain): 69.40% vs. 68.99% mIoU (minimal difference).
  • In Virginia (out-of-domain): 45.56% vs. 33.14% mIoU (+12.42 points).
  • In New York: 57.95% vs. 49.26% mIoU (+8.69 points).

Limitations and Future Work

  • Runtime Compute vs. Disk Space Trade-off: On-the-fly reprojection and resampling save substantial disk space and manual effort, but raw un-cached sampling is noticeably slower than reading pre-processed, statically aligned patches.
  • Sensor Incompatibility: Because sensor specifications (wavelengths, bands, ground resolution) vary drastically across satellite platforms, a single pre-trained checkpoint cannot easily transfer directly across platforms (e.g., Landsat vs. Sentinel vs. commercial Maxar imagery).
  • Future Directions: Incorporating geospatial-specific inductive biases (such as rotation equivariance), multi-modal fusion mechanisms, self-supervised spatial representation methods (e.g., Tile2Vec, SeCo), and learning directly from vector shapes.

Summary updated

BibTeX
@inproceedings{stewart2022torchgeo,
  author = {Adam J Stewart and Caleb Robinson and Isaac A Corley and Anthony Ortiz and Juan M Lavista Ferres and Arindam Banerjee},
  title = {{TorchGeo: deep learning with geospatial data}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=ZgV2C9NKk6Q},
}
Figure