🚀 A comprehensive library for generating ML-ready geospatial dataset 🌍
Installation
We recommend using uv to manage your Python projects.
If you haven’t created a uv-managed project yet, create one:
uv init terrakit-demo
cd terrakit-demo
Then add TerraKit to your project dependencies:
uv add terrakit
Alternatively, for projects using pip for dependencies:
pip install terrakit
Check TerraKit is working as expected by running:
python -c "import terrakit; data_source='sentinel_aws'; dc = terrakit.DataConnector(connector_type=data_source)"
NOTE: Activate the uv virtual environment using source .venv/bin/activate. Alternatively use uv run ahead of any python and pip commands.
NOTE: TerraKit requires gdal to be installed, which can be quite a complex process. If you don’t have GDAL set up on your system, we recommend using uv as follows assuming you are running on a linux system:
Alternatively, you can use a conda environment and installing it with conda install -c conda-forge gdal.
PyTorch Conference Europe 2026
Watch TerraKit in action at the PyTorch Conference Europe 2026:
Data Connectors
Data connectors are classes which enable a user to search for data and query data from a particular data source using a common set of functions. Each data connector has the following mandatory methods:
list_collections()
find_data()
get_data()
Available data connectors
The following data connectors and associated collections are available:
We can also run TerraKit using the CLI. Take a look at the TerraKit CLI Notebook for some examples of how to use this.
Data connector access
Each data connector has a different access requirements. For connecting to SentinelHub and NASA EarthData, you will need to obtain credentials from each provider. Once these have been obtained, they can be added to a .env file at the root directory level using the following syntax:
SH_CLIENT_ID="<SentinelHub Client ID>"
SH_CLIENT_SECRET="<SentinelHub Client Secret>"
NASA_EARTH_BEARER_TOKEN="<NASA EarthData Bearer Token>"
CDSAPI_KEY="<Climate Data Store API Key>"
To access sentinel hub, register for an account and requests an OAuth client using the Sentinel Hub dashboard https://www.planet.com
Sentinel AWS
Access sentinel AWS data is open and does not require any credentials.
Climate Data Store
Create an account at https://cds.climate.copernicus.eu/. Once created, find your API key under the Profile section and add to your .env file. Each dataset may also require accepting the licence agreement. If this is the case, the first time a request is made, an error will be returned with the url to visit to accept the terms.
Access IBM Research STAC is currently restricted to IBMers and partners. If you’re elegible, you need to register for an IBM AppID account and set the following environment variables:
IBMers don’t need credentials to access the internal instance of the STAC service.
This data connector allows you to save files as netcdf or tif. The get_data(..) method has a parameter called save_file. If you set save_file to a path that ends with nc then it will save as netcdf. If you set to a path that ends with tif it will save as tif files.
Example data
To download a pair of example label files from Copernicus Emergency Management Service, use the rapid_mapping_geojson_downloader function as follows:
git clone git@github.com/torchgeo/terrakit.git
cd terrakit
Install uv package manger using pip install uv, then install the package dependencies:
uv sync
Test out TerraKit:
uv run python -c "from terrakit import DataConnector; dc = DataConnector(connector_type='nasa_earthdata')"
Setup dev dependencies
Install dev dependencies
uv sync --group dev
If needed, dev dependencies can be excluded using the following:
uv sync --no-group dev
Check venv is set up as expected:
uv venv check
To install a new package and include it in the uv environment:
uv add <new_package>; uv sync.
Install pre-commit
Install the .pre-commit-config.yaml:
uv run pre-commit install
NOTE:Follow the steps under Detect secrets to install the IBM Detect Secrets library used by one of the pre-commit hooks.
To run pre-commit tasks which include ruff format, pytest, pytest coverage, detect secrets and mypy:
uv run pre-commit
The pre-commit tasks will run before as part of a git commit command. If any of the pre-commit tasks fail, git commit will also fail. Please resolve any issues before re running git commit.
Ruff usage
Run the Ruff formatter on the given files or directories
ruff format <file or directory name>
Use the [ruff.tool] > ignore section to include rules which should be ignored.
Run the following command from within the root directory to scan it for existing secrets, logging the results in .secrets.baseline.
uv run detect-secrets scan --update .secrets.baseline
Running pytests
To run all unit tests:
uv run pytest
To complete a pytest coverage report:
uv run pytest --cov=src/terrakit tests/
Running integration tests
uv run python tests/integration_tests/dev.py
Add a new data connectors
To add a new data connector, use the connector_template.py as a starting point. The new connector should implement the list_collection, find_data and get_data functions and extend the Connector class from the terrakit.download.connector module. Finally update terrakit.py to enable the new connector to be selected.
TerraKit
🚀 A comprehensive library for generating ML-ready geospatial dataset 🌍
Installation
We recommend using uv to manage your Python projects.
If you haven’t created a uv-managed project yet, create one:
Then add TerraKit to your project dependencies:
Alternatively, for projects using pip for dependencies:
Check TerraKit is working as expected by running:
NOTE: TerraKit requires gdal to be installed, which can be quite a complex process. If you don’t have GDAL set up on your system, we recommend using
uvas follows assuming you are running on a linux system:Alternatively, you can use a conda environment and installing it with conda install -c conda-forge gdal.
PyTorch Conference Europe 2026
Watch TerraKit in action at the PyTorch Conference Europe 2026:
Data Connectors
Data connectors are classes which enable a user to search for data and query data from a particular data source using a common set of functions. Each data connector has the following mandatory methods:
Available data connectors
The following data connectors and associated collections are available:
Quick start
Here is an example using the SentinelHub data connector.
To list available bands:
For more examples, take a look at terrakit_download.ipynb.
TerraKit CLI
We can also run TerraKit using the CLI. Take a look at the TerraKit CLI Notebook for some examples of how to use this.
Data connector access
Each data connector has a different access requirements. For connecting to SentinelHub and NASA EarthData, you will need to obtain credentials from each provider. Once these have been obtained, they can be added to a
.envfile at the root directory level using the following syntax:NASA Earthdata
To access NASA Earthdata, register for an Earthdata Login profile and requests a bearer token. https://urs.earthdata.nasa.gov/profile
Sentinel Hub
To access sentinel hub, register for an account and requests an OAuth client using the Sentinel Hub dashboard https://www.planet.com
Sentinel AWS
Access sentinel AWS data is open and does not require any credentials.
Climate Data Store
Create an account at https://cds.climate.copernicus.eu/. Once created, find your API key under the
Profilesection and add to your.envfile. Each dataset may also require accepting the licence agreement. If this is the case, the first time a request is made, an error will be returned with the url to visit to accept the terms.Available collections include:
The Weather Company
To access The Weather Company, register for an account and requests an API Key https://www.weathercompany.com/weather-data-apis/. Once you have an API key, set the following environment variable:
IBM Research STAC
Access IBM Research STAC is currently restricted to IBMers and partners. If you’re elegible, you need to register for an IBM AppID account and set the following environment variables:
Please reach out the maintainers of this repo.
IBMers don’t need credentials to access the internal instance of the STAC service.
This data connector allows you to save files as netcdf or tif. The
get_data(..)method has a parameter calledsave_file. If you setsave_fileto a path that ends withncthen it will save as netcdf. If you set to a path that ends withtifit will save as tif files.Example data
To download a pair of example label files from Copernicus Emergency Management Service, use the
rapid_mapping_geojson_downloaderfunction as follows:Development setup
Git clone this repo:
Install
uvpackage manger usingpip install uv, then install the package dependencies:Test out TerraKit:
Setup dev dependencies
Install dev dependencies
If needed, dev dependencies can be excluded using the following:
Check venv is set up as expected:
To install a new package and include it in the uv environment:
Install pre-commit
Install the
.pre-commit-config.yaml:To run pre-commit tasks which include ruff format, pytest, pytest coverage, detect secrets and mypy:
The pre-commit tasks will run before as part of a
git commitcommand. If any of the pre-commit tasks fail,git commitwill also fail. Please resolve any issues before re runninggit commit.Ruff usage
Run the Ruff formatter on the given files or directories
Use the [ruff.tool] > ignore section to include rules which should be ignored.
Detect secrets
Install IBM detect secrets:
Run the following command from within the root directory to scan it for existing secrets, logging the results in .secrets.baseline.
Running pytests
To run all unit tests:
To complete a pytest coverage report:
Running integration tests
Add a new data connectors
To add a new data connector, use the connector_template.py as a starting point. The new connector should implement the
list_collection,find_dataandget_datafunctions and extend theConnectorclass from theterrakit.download.connectormodule. Finally update terrakit.py to enable the new connector to be selected.To also include new tests for the new connector, please make use of test_connector_template.py.
Make sure to also update the documentation. Each data connector has a separate markdown file making it easy to add new docs.