StackMoth/Work/Land evaluation engine

Geospatial & data

Landscape-scale crop evaluation grounded against national survey polygons

A 10-stage GIS and remote-sensing pipeline scoring 2,667 candidate blocks across eight crops in Sri Lanka’s Ratnapura District.

2,667Candidate blocks
1,304Calibration polygons
10Cached stages
8Evaluated crops

An uncalibrated suitability envelope required 55% sand for top-grade cinnamon — a threshold not one mapped cinnamon polygon in Sri Lanka actually meets.

10 cached, idempotent GIS stages
fetch ──► derive ──► calibrate ──► score ──► blocks │ site ◄── export ◄── report ◄── detect ◄── context

Engineering notes

Pipeline, calibration & charts

01Facts
Region
Rakwana area, Ratnapura District, Sri Lanka
Scale
~27,700 lines of Python & web code, 2,667 blocks, 8 crops
Data sources
3 DEMs, SoilGrids, Sentinel-2, CHIRPS, ERA5, NSDI, 0.6 m imagery
Calibration
368 cinnamon polygons (6,219 ha) & 936 tea polygons
Stack
Python (NumPy, SciPy, Shapely, PyProj, Rasterio), Leaflet
Outputs
Google Earth .kmz, .gpx, ranked CSV & static web map
02Ten cached, idempotent stages & factor discrimination

Every remote fetch is keyed and cached on disk so the pipeline needs no API keys and re-runs cleanly stage by stage. It fuses three 30 m elevation models (Copernicus GLO-30, ALOS AW3D30 and NASADEM), SoilGrids v2.0, Sentinel-2 L2A composites, CHIRPS rainfall, ERA5 daily series, national NSDI survey layers and 0.6 m imagery to compute terrain, hydrology, erosion, landslide screening, canopy vigour and financial NPV ranges per block.

Horizontal bar chart comparing standard deviation of environmental factor scores across the study area against the percentage of the area scoring the maximum.
Factor discrimination across the 5 km study area: rainfall and soil pH score maximum across 100% of the terrain, leaving slope, wetness and elevation as the actual discriminators.
03Catching a calibration flaw against ground truth

Every mapped cinnamon polygon sits between 27% and 31% sand, which meant the initial textbook model made genuine cinnamon land impossible to classify as highly suitable. Recalibrating soil factors against 368 mapped cinnamon polygons (6,219 ha) and 936 tea polygons lifted the real cinnamon belt to 97.8% S1/S2 suitability while holding elevation, rainfall and temperature on published agronomy bounds.

04Quantifying coverage bias & crop NPV trade-offs

Rather than treating an absence of mapped polygons as proof that a crop cannot grow, the context stage audits the national survey layer itself: within a 50 km circle only 13.4% of the box is surveyed at all, concentrated in the lowland strip, with nothing mapped within 12.9 km of the upland study point. What survives that bias is the direct comparison inside the surveyed strip — mapped cinnamon sits at a median 35 m elevation against tea’s 94 m, explaining why tea suits the 857 m upland site while commercial cinnamon sits 5–6 km down-slope at 320–340 m.

Scatter plot of biophysical suitability from 0.45 to 1.0 against NPV per hectare in LKR million with low-central-high range bars for eight crops.
Biophysical suitability plotted against low–central–high NPV ranges per hectare across all eight evaluated crops.
05Catching upstream sensor and archive bugs
  • Sentinel-2 baseline 04.00 offset: ESA added a −1000 reflectance offset in January 2022 that STAC metadata did not expose; ignoring it made 99.8% of the landscape appear to decline in NDVI until corrected per scene.
  • ERA5-Land null precipitation: Open-Meteo’s archive returned all-NaN precipitation for ERA5-Land, so rainfall surfaces route strictly from CHIRPS 2.0 while reanalysis supplies temperature and ET₀.
  • Synthetic feature and leak-guard tests: test_detect.py runs offline against synthetic striped canopies, coppice cycles and deliberate leak features to prove grouped cross-validation holds groups out honestly.

AI-assisted, human-accountable. AI tools contributed significantly to the implementation described here. The specification, the review of every change, the production operation and the accountability are mine.

Next case study

PT Tracker