torchgeo/torchgeo

TorchGeo: datasets, samplers, transforms, and pre-trained models for geospatial data

TorchGeo – Geospatial Deep‑Learning Toolkit for PyTorch

What it is – TorchGeo is a PyTorch‑compatible library that bundles ready‑made geospatial datasets, samplers, transforms, and pre‑trained models. Think of it as torchvision for satellite and aerial imagery.

Why it matters – Remote‑sensing data comes with extra complications: many spectral bands, varying spatial resolutions, and different coordinate reference systems (CRS). TorchGeo hides this plumbing so ML researchers can focus on models, and remote‑sensing experts can experiment with deep‑learning pipelines without writing low‑level data‑handling code.

Key features (as described in the README)

  • Datasets & metadata handling – Provides GeoDataset subclasses for popular sources (Landsat 7/8, Sentinel, Cropland Data Layer, VHR‑10, etc.). Datasets can be combined with set‑like operators (| for union, & for intersection) that automatically align CRS and resolution.
  • SamplersRandomPatchSampler and others let you draw fixed‑size patches (e.g., 256 × 256) from massive images, returning a configurable number of samples per epoch.
  • Benchmark collections – Ready‑to‑use labeled datasets for classification, regression, semantic segmentation, object detection, change detection, etc., mirroring the API style of torchvision.
  • Pre‑trained weights – Supports multi‑spectral weights (e.g., Sentinel‑2‑pre‑trained ResNet‑18) via the torchvision multi‑weight API and the timm model zoo.
  • Lightning integration – Supplies Lightning DataModules and Task objects (e.g., SemanticSegmentation) with built‑in augmentations (kornia) and channel statistics, enabling a few‑line training script or full CLI usage via torchgeo/LightningCLI.
  • Installation – Available on PyPI, conda‑forge, and spack; also installable with uv.
  • Community & docs – Slack, OSGeo, Radiant Earth, Hugging Face, YouTube channel, and full ReadTheDocs site with tutorials and API reference.

Typical workflow

  1. Import a dataset (e.g., Landsat8) and optionally combine it with another (e.g., CDL).
  2. Create a sampler to extract patches.
  3. Wrap the dataset in a DataLoader (or use a provided Lightning DataModule).
  4. Train a model—either a custom architecture or a pre‑trained one—using PyTorch Lightning.

Citation – If you publish work using TorchGeo, cite the ACM Transactions on Spatial Algorithms and Systems paper (2025).


All details above are taken directly from the project's README; no external assumptions have been added.

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Project