TerraFlow: A Reproducible Geospatial Suitability Framework
TerraFlow is a reproducible, config-driven framework for climate-impact assessment of agricultural suitability. Give it a land-cover raster, a climate CSV (weather-station observations), and a YAML config — it returns a scored, location-stamped per-cell results table with full provenance and per-cell uncertainty intervals. As of v0.5.0 the framework also fans out climate-induced crop hazards (growing-degree days, frost days, heat-stress days, precipitation percentiles, simplified Thornthwaite SPEI) across arbitrary CMIP6 SSP scenario windows, writing a sibling climate_features.parquet artifact alongside the historical suitability score. The same workflow methodology extends to habitat suitability, land-use planning, and conservation siting.
Documentation: terraflow.marupilla.dev — see the Reproducibility page for what the run fingerprint covers and known sources of non-determinism.
At a Glance
flowchart LR
CFG["Config<br/>(YAML + Pydantic)"] --> PIPE["Pipeline<br/>(orchestration)"]
PIPE --> ING["Ingest<br/>(raster, climate CSV,<br/>timeseries CSV / CMIP6)"]
PIPE --> GEO["Geospatial<br/>(ROI clip, CRS)"]
PIPE --> CIM["Climate impact<br/>(temporal, hazard,<br/>CMIP6)"]
PIPE --> MOD["Model<br/>(suitability scoring)"]
PIPE --> OUT["Outputs<br/>(features.parquet,<br/>climate_features.parquet,<br/>manifest, report)"]
ING --> GEO
ING --> CIM
ING --> MOD
GEO --> MOD
CIM --> OUT
MOD --> OUT
| Property | What TerraFlow guarantees |
|---|---|
| Deterministic outputs | Same config + same inputs → bit-identical results, addressed by run fingerprint |
| Provenance | Every run writes a manifest.json capturing config, input hashes, software versions, and fingerprint |
| Spatial validation | Spatial-block CV (terraflow validate) |
| Sensitivity analysis | Sobol' / Morris indices for model weights (terraflow sensitivity) |
| Uncertainty quantification | Kriging Monte Carlo → score CIs (score_ci_low / score_ci_high) |
| Distribution | PyPI (terraflow-agro) + Homebrew (gmarupilla/terraflow) + Docker |
| Citation | Citable via CITATION.cff and Zenodo DOI 10.5281/zenodo.21070362; JOSS paper resubmission pending adoption signal |
Drought-impact prediction benchmark
terraflow drought builds and evaluates an impact-labeled drought benchmark — predicting
insured drought loss (USDA RMA Cause of Loss) from within-season climate/vegetation anomalies.
It is a decision-relevant impact target, distinct from drought severity (USDM D2+) and crop
yield benchmarks (CY-Bench, SustainBench).
terraflow drought fetch --rma-dir data/drought/rma --year-min 2000 --year-max 2023
terraflow drought build -c examples/drought_v0_corn_6state.yml
terraflow drought evaluate -c examples/drought_v0_corn_6state.yml
Dataset on Zenodo: 10.5281/zenodo.21208651 (CC-BY-4.0). See the drought benchmark guide.
Installation
macOS (Homebrew) — handles GDAL and PROJ automatically:
brew tap gmarupilla/terraflow
brew install terraflow
pip / uv:
uv pip install terraflow-agro
# or
pip install terraflow-agro
For kriging-based interpolation:
pip install terraflow-agro pykrige
See Homebrew install docs for update/uninstall instructions and troubleshooting.
Quickstart
terraflow run --config config.yml
A minimal config:
raster_path: "data/land_cover.tif"
climate_csv: "data/climate.csv"
output_dir: "outputs"
roi:
type: bbox
xmin: -120.5
ymin: 34.0
xmax: -118.0
ymax: 35.5
model_params:
v_min: 0.0
v_max: 1.0
t_min: 10.0
t_max: 35.0
r_min: 100.0
r_max: 800.0
w_v: 0.4
w_t: 0.3
w_r: 0.3
Results are written to outputs/runs/<fingerprint>/:
features.parquet — scored cells (lat, lon, score, label, …)
results.csv — same data in CSV
manifest.json — full provenance record
report.json — QA stats and timings
CLI subcommands
| Subcommand | Purpose |
|---|---|
terraflow run -c config.yml |
Run the full pipeline. Auto-invokes the climate-impact path (scenario × hazard fan-out) when both climate.temporal_aggregations and climate.scenarios are set in the config. |
terraflow sensitivity -c config.yml |
Sobol' / Morris sensitivity indices for model weights |
terraflow validate -c config.yml |
Spatial block CV |
See CLI docs for full reference. End-to-end climate-impact example: examples/demo_config_climate_impact.yml + the demo notebook.
Climate interpolation
Three spatial algorithms are available via interpolation_method:
| Method | Notes |
|---|---|
linear (default) |
scipy.griddata — fast, no extra deps |
kriging |
Ordinary Kriging via pykrige; adds {var}_krig_std uncertainty columns |
idw |
Inverse Distance Weighting (power=2) — faster than kriging, no uncertainty |
Combine interpolation_method: kriging with uncertainty_samples: N in model_params to get Monte Carlo score confidence intervals (score_ci_low / score_ci_high).
For kriging, variogram_mode: extended evaluates additional nested variogram candidates and records all LOOCV candidate scores in report.json; use the default standard mode for large station networks unless nested structures are needed. See the extended variogram notebook in the docs for a worked synthetic example.
See Config Schema for the full reference.
Python API
from terraflow.pipeline import run_pipeline
results_df = run_pipeline("config.yml")
Development
git clone https://github.com/gmarupilla/AgroTerraFlow.git
cd AgroTerraFlow
make dev # create .venv and install dev deps
make test # run test suite
make lint # ruff + black
make docs-build
Architecture
Core modules: cli, config, pipeline, model, ingest, geo, climate, climate_impact, temporal, hazard, cmip6, sensitivity, validation, core/run_identity, stats, exceptions, utils, viz.
Run artifacts under <output_dir>/runs/<fingerprint>/ include features.parquet, manifest.json, report.json, and results.csv. When kriging is configured, report.json also carries kriging_diagnostics (model, nugget, sill, range), kriging_loocv RMSE per variable, uncertainty coverage, and an interpolation_fallback block with per-variable fallback-to-mean counts. Multi-band rasters are supported via the top-level raster_band field (1-based; default 1).
Key design decisions are documented in Architecture Decision Records under docs/architecture/. See docs/reproducibility.md for the run fingerprint contract and known sources of non-determinism.
Project Scope
TerraFlow is a reproducible pipeline for geospatial agricultural modeling. It handles raster ingestion, ROI clipping, climate interpolation, suitability scoring, and deterministic artifact generation.
In scope:
- Configuration-driven pipeline execution (YAML → Parquet + provenance artifacts)
- Spatial interpolation of point climate observations (linear, kriging, IDW)
- Per-cell suitability scoring with uncertainty quantification (Monte Carlo)
- Deterministic run fingerprinting and artifact caching
Out of scope:
- Real-time data ingestion or streaming workflows
- General-purpose raster analysis (use
rioxarrayorrasterstatsinstead) - Cloud-scale distributed processing (no Dask/Spark integration planned)
- Web application or GUI layer
Maintenance & Support
TerraFlow is actively maintained. Bug fixes are prioritized; the test suite and CI pipeline are kept green on every commit.
Feature requests are evaluated against project scope — open an issue to discuss before building. Not all requests will be accepted.
Support is provided on a best-effort basis via GitHub Issues. Response time is typically within a week. There is no paid support tier.
Contributing
See CONTRIBUTING.md.
Citation
If you use TerraFlow in your research, please cite the archived Zenodo release:
Marupilla, G. (2026). TerraFlow: A Reproducible Framework for Climate-Impact Assessment of Agricultural Suitability (v0.5.0). Zenodo. https://doi.org/10.5281/zenodo.21070362
CITATION.cff carries the canonical metadata. A companion JOSS paper is
drafted and will be resubmitted once external adoption signal materialises;
see the postmortem at https://github.com/openjournals/joss-reviews/issues/10686.
License
MIT License — free for academic, commercial, and open-source use.
Metadata
Release files for terraflow-agro 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| terraflow_agro-0.6.0.tar.gz | 127.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| terraflow_agro-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 215.6 kB
Release files / terraflow_agro-0.6.0.tar.gz
| Download URL | terraflow_agro-0.6.0.tar.gz |
|---|---|
| Size | 127.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22616dccde9538ce755359041342de9b399eb45bb160d9b0f45688ac8025b9ce
|
|
BLAKE2b-256 checksum How to use checksums |
e6bcb40bbd58892755e9e7848b2cddb0f337b23da8e332229139bfacf6b1f6f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / terraflow_agro-0.6.0-py3-none-any.whl
| Download URL | terraflow_agro-0.6.0-py3-none-any.whl |
|---|---|
| Size | 87.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b1a77167a0c693ac1b94979f75d50763552fedaf717b44be853364a65db0690
|
|
BLAKE2b-256 checksum How to use checksums |
2053c934540c69a4892f4df4b374917784667b88d8e26ef402df14dd5dee20cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|