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.
An uncalibrated suitability envelope required 55% sand for top-grade cinnamon — a threshold not one mapped cinnamon polygon in Sri Lanka actually meets.
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.
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.
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.pyruns 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.