torchgeo
TorchGeo: datasets, samplers, transforms, and pre-trained models for geospatial data
What it is and what it does
TorchGeo is a domain library built on PyTorch that bridges machine learning and geospatial data science. It provides curated datasets for satellite imagery (Landsat, Sentinel, and others), samplers that intelligently extract patches from large geographic regions, and pre-trained models adapted for multispectral remote sensing tasks. The library automatically handles the complexity of geospatial work—reprojecting data into matching coordinate reference systems, aligning different satellite sources with different spectral bands, and composing datasets through set operations (union and intersection) based on geographic coverage.
The package targets two audiences: ML practitioners who want to work with satellite and earth observation data without wrestling with geospatial coordinate systems, and remote sensing experts exploring deep learning solutions. It includes both large-scale geospatial datasets (where you sample patches from continental-scale imagery) and benchmark datasets with pre-labeled examples for tasks like object detection, semantic segmentation, and change detection. All datasets integrate seamlessly with PyTorch data loaders and Lightning training pipelines.
Use it for:
- Train semantic segmentation models on Landsat or Sentinel satellite imagery with automatic CRS alignment and band selection.
- Build object detection systems on high-resolution aerial imagery using the VHR-10 benchmark dataset.
- Combine multispectral satellite data from different sensors (e.g., Landsat 7 and 8) into a single training dataset.
- Sample random geographic patches from continental-scale raster data like the Cropland Data Layer for efficient batch training.
- Transfer-learn from pre-trained models adapted for multispectral channels beyond standard RGB imagery.
- Prototype change detection or land-use classification pipelines on real remote sensing data with minimal data wrangling.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
TorchGeo provides PyTorch datasets, samplers, transforms, and pre-trained models for geospatial and remote sensing data, handling multispectral satellite imagery with automatic coordinate reference system alignment.
Yes, if you are working with satellite or geospatial imagery in a PyTorch workflow. The library solves real problems—automatic CRS reprojection, multispectral band alignment, and intelligent patch sampling from large rasters—that would otherwise require substantial custom code. Active maintenance, MIT license, and integration with Lightning make it a solid foundation. The 22 runtime dependencies are heavy but standard for this domain; install time and disk footprint are expected costs. Not necessary if your geospatial work is small-scale or already handled by other tools.
Install
torchgeo on PyPI
pip
pip install torchgeouv
uv add torchgeopoetry
poetry add torchgeoInstalling torchgeo
Before you install
Low friction installation with a pure Python wheel. The 22 runtime dependencies include heavy ML stacks (torch, torchvision, lightning, kornia, segmentation-models-pytorch) that will pull in substantial compiled code; installation time and disk footprint are non-trivial but standard for PyTorch-based geospatial work. Actively maintained as of 2026-08-14.
License in practice
MIT license is permissive; you can use, modify, and distribute TorchGeo with minimal restrictions, including in commercial projects, provided you retain the license notice.
Quickstart
pip install torchgeo
from torchgeo.datasets import Landsat8, CDL
from torchgeo.samplers import RandomPatchSampler
from torch.utils.data import DataLoader
landsat = Landsat8(paths='...')
cdl = CDL(paths='...', download=True)
dataset = landsat & cdl
sampler = RandomPatchSampler(dataset, size=256, length=10000)
loader = DataLoader(dataset, batch_size=128, sampler=sampler)
Requires PyTorch and torchvision to be installed; torch and torchvision are heavy compiled dependencies that may take time to download and build on some systems.
Verify before relying
- Whether pre-trained model weights for multispectral channels are included in the package or must be downloaded separately.
- Performance characteristics when working with very large geospatial datasets (e.g., continental-scale imagery).
- Specific remote sensing data formats and coordinate reference systems supported beyond the examples in the description.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 22 — einops, geopandas, jsonargparse, kornia, lightly, lightning, matplotlib, numpy, pandas, pillow, pyogrio, pyproj, rasterio, requests, segmentation-models-pytorch, shapely, timm, torch, torchmetrics, torchvision, tqdm, typing-extensions |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 79,184/month — #14,375 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torchgeo-0.10.0-py3-none-any.whl
Keywords: pytorch, deep learning, machine learning, remote sensing, satellite imagery, earth observation, geospatial
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
torchvisionTorchvision provides pre-built datasets, model…
permissive · top 1,000 on PyPI
torchxrayvisionTorchXRayVision provides pre-trained deep…
permissive · top 15,000 on PyPI
torchtexttorchtext provides text datasets, preprocessing…
permissive · top 15,000 on PyPI
owslibOWSLib provides Python client access to Open…
permissive · top 15,000 on PyPI
earthengine-apiPython client library for Google Earth Engine,…
permissive · top 15,000 on PyPI
geemapGeemap provides interactive geospatial analysis…
permissive · top 15,000 on PyPI
datacubeDatacube provides an integrated gridded data…
permissive · top 15,000 on PyPI
sentinelhubsentinelhub provides a Python interface to…
permissive · top 15,000 on PyPI
torchrlTorchRL is a PyTorch-native toolkit for…
unclear · top 5,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI