# microsoft/torchgeo architecture

> Architecture diagram of the GitHub repository microsoft/torchgeo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/torchgeo
- Repository: https://github.com/microsoft/torchgeo

## Overview

TorchGeo is a PyTorch domain library for geospatial machine learning. The principal workflow composes georeferenced imagery and labels, samples geographic patches, batches samples through a data module, and supplies them to a training task. Its broader capabilities include benchmark datasets, transforms, model architectures and pretrained weights, self-supervised learning, and prediction output. The README documents the user workflow; sampled source confirms dataset, sampler, and data-module responsibilities. Several model and task implementations are represented from the source index, so their internal connections are not asserted.

Main entry points: [`torchgeo/tasks`](https://github.com/microsoft/torchgeo/tree/main/torchgeo/tasks) (Training tasks), [`torchgeo/datamodules/geo.py`](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datamodules/geo.py) (Data modules), [`torchgeo/datasets/geo.py`](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/geo.py) (Raster datasets), [`torchgeo/main.py`](https://github.com/microsoft/torchgeo/blob/main/torchgeo/main.py) (Training CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Geospatial data"]
  node_raster["Raster datasets<br/>[geo.py]"]
  node_benchmark["Benchmark datasets"]
  node_bigearthnet["BigEarthNet<br/>[bigearthnet.py]"]
  node_chesapeake["Chesapeake<br/>[chesapeake.py]"]
  node_dataset_utils["Dataset utilities<br/>[utils.py]"]
end

subgraph group_input["Sampling and input"]
  node_samplers["Geospatial samplers"]
  node_datamodule["Data modules<br/>[geo.py]"]
  node_transforms["Data transforms"]
end

subgraph group_learning["Models and learning"]
  node_tasks["Training tasks"]
  node_task_base["Task base<br/>[base.py]"]
  node_moco["MoCo learning<br/>[moco.py]"]
  node_byol["BYOL learning<br/>[byol.py]"]
  node_resnet["ResNet models<br/>[resnet.py]"]
  node_convlstm["ConvLSTM model<br/>[convlstm.py]"]
  node_earthloc["EarthLoc model<br/>[earthloc.py]"]
  node_ltae["L-TAE model<br/>[ltae.py]"]
  node_presto["Presto model<br/>[presto.py]"]
  node_model_catalog["Other model architectures"]
  node_losses["Specialized losses"]
end

subgraph group_support["Training support"]
  node_cli["Training CLI<br/>[main.py]"]
  node_writer["Prediction writer<br/>[writer.py]"]
end

node_user(("ML user"))

node_user -->|"composes data"| node_raster
node_user -->|"selects benchmark"| node_benchmark
node_raster -->|"sample patches"| node_samplers
node_benchmark -.->|"loads batches"| node_datamodule
node_raster -->|"loads dataset"| node_datamodule
node_datamodule -->|"configures samplers"| node_samplers
node_datamodule -->|"supplies batches"| node_tasks
node_transforms -.->|"transforms samples"| node_raster
node_tasks -.->|"uses models"| node_resnet
node_tasks -.->|"uses models"| node_model_catalog
node_moco -->|"extends task"| node_task_base
node_byol -->|"extends task"| node_task_base
node_cli -->|"configures data"| node_datamodule
node_cli -->|"configures tasks"| node_tasks
node_tasks -.->|"writes predictions"| node_writer

click node_raster "https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/geo.py"
click node_benchmark "https://github.com/microsoft/torchgeo/tree/main/torchgeo/datasets"
click node_bigearthnet "https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/bigearthnet.py"
click node_chesapeake "https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/chesapeake.py"
click node_dataset_utils "https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/utils.py"
click node_samplers "https://github.com/microsoft/torchgeo/tree/main/torchgeo/samplers"
click node_datamodule "https://github.com/microsoft/torchgeo/blob/main/torchgeo/datamodules/geo.py"
click node_transforms "https://github.com/microsoft/torchgeo/tree/main/torchgeo/transforms"
click node_tasks "https://github.com/microsoft/torchgeo/tree/main/torchgeo/tasks"
click node_task_base "https://github.com/microsoft/torchgeo/blob/main/torchgeo/tasks/base.py"
click node_moco "https://github.com/microsoft/torchgeo/blob/main/torchgeo/tasks/moco.py"
click node_byol "https://github.com/microsoft/torchgeo/blob/main/torchgeo/tasks/byol.py"
click node_resnet "https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/resnet.py"
click node_convlstm "https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/convlstm.py"
click node_earthloc "https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/earthloc.py"
click node_ltae "https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/ltae.py"
click node_presto "https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/presto.py"
click node_model_catalog "https://github.com/microsoft/torchgeo/tree/main/torchgeo/models"
click node_losses "https://github.com/microsoft/torchgeo/tree/main/torchgeo/losses"
click node_cli "https://github.com/microsoft/torchgeo/blob/main/torchgeo/main.py"
click node_writer "https://github.com/microsoft/torchgeo/blob/main/torchgeo/callbacks/writer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raster,node_benchmark,node_bigearthnet,node_chesapeake,node_dataset_utils,node_user toneBlue
class node_samplers,node_datamodule,node_transforms toneAmber
class node_tasks,node_task_base,node_moco,node_byol,node_resnet,node_convlstm,node_earthloc,node_ltae,node_presto,node_model_catalog,node_losses toneMint
class node_cli,node_writer toneRose
```

## Components

### Geospatial data

- [Raster datasets](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/geo.py): `torchgeo/datasets/geo.py`
- [Benchmark datasets](https://github.com/microsoft/torchgeo/tree/main/torchgeo/datasets): `torchgeo/datasets`
- [BigEarthNet](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/bigearthnet.py): `torchgeo/datasets/bigearthnet.py`
- [Chesapeake](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/chesapeake.py): `torchgeo/datasets/chesapeake.py`
- [Dataset utilities](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datasets/utils.py): `torchgeo/datasets/utils.py`

### Sampling and input

- [Geospatial samplers](https://github.com/microsoft/torchgeo/tree/main/torchgeo/samplers): `torchgeo/samplers`
- [Data modules](https://github.com/microsoft/torchgeo/blob/main/torchgeo/datamodules/geo.py): `torchgeo/datamodules/geo.py`
- [Data transforms](https://github.com/microsoft/torchgeo/tree/main/torchgeo/transforms): `torchgeo/transforms`

### Models and learning

- [Training tasks](https://github.com/microsoft/torchgeo/tree/main/torchgeo/tasks): `torchgeo/tasks`
- [Task base](https://github.com/microsoft/torchgeo/blob/main/torchgeo/tasks/base.py): `torchgeo/tasks/base.py`
- [MoCo learning](https://github.com/microsoft/torchgeo/blob/main/torchgeo/tasks/moco.py): `torchgeo/tasks/moco.py`
- [BYOL learning](https://github.com/microsoft/torchgeo/blob/main/torchgeo/tasks/byol.py): `torchgeo/tasks/byol.py`
- [ResNet models](https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/resnet.py): `torchgeo/models/resnet.py`
- [ConvLSTM model](https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/convlstm.py): `torchgeo/models/convlstm.py`
- [EarthLoc model](https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/earthloc.py): `torchgeo/models/earthloc.py`
- [L-TAE model](https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/ltae.py): `torchgeo/models/ltae.py`
- [Presto model](https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/presto.py): `torchgeo/models/presto.py`
- [Other model architectures](https://github.com/microsoft/torchgeo/tree/main/torchgeo/models): `torchgeo/models`
- [Specialized losses](https://github.com/microsoft/torchgeo/tree/main/torchgeo/losses): `torchgeo/losses`

### Training support

- [Training CLI](https://github.com/microsoft/torchgeo/blob/main/torchgeo/main.py): `torchgeo/main.py`
- [Prediction writer](https://github.com/microsoft/torchgeo/blob/main/torchgeo/callbacks/writer.py): `torchgeo/callbacks/writer.py`

### Other components

- **ML user**

## Connections

- ML user → Raster datasets: composes data
- ML user → Benchmark datasets: selects benchmark
- Raster datasets → Geospatial samplers: sample patches
- Benchmark datasets → Data modules: loads batches (evidence: `torchgeo/datamodules/geo.py`)
- Raster datasets → Data modules: loads dataset (evidence: `torchgeo/datamodules/geo.py`)
- Data modules → Geospatial samplers: configures samplers (evidence: `torchgeo/datamodules/geo.py`)
- Data modules → Training tasks: supplies batches
- Data transforms → Raster datasets: transforms samples
- Training tasks → ResNet models: uses models
- Training tasks → Other model architectures: uses models (evidence: `torchgeo/tasks/moco.py`)
- MoCo learning → Task base: extends task (evidence: `torchgeo/tasks/moco.py`)
- BYOL learning → Task base: extends task (evidence: `torchgeo/tasks/byol.py`)
- Training CLI → Data modules: configures data (evidence: `torchgeo/main.py`)
- Training CLI → Training tasks: configures tasks (evidence: `torchgeo/main.py`)
- Training tasks → Prediction writer: writes predictions
