Skip to content

Commit 11d95f1

Browse files
committed
feat: soil intelligence & decision support (v0.8.0)
Milestone 11 - Soil Intelligence & Decision Support: - Soil intelligence engine (2,200+ lines) with crop suitability, nutrient analysis, carbon estimation, sampling zones, stress monitoring - 4-pillar crop suitability scoring (Soil 40%, Water 25%, Climate 20%, Stress 15%) with 68 crop profiles - Weather-aware suitability integrating rainfall, temperature, drought/flood indices - Sampling zone recommendations from within-field soil variability analysis - Nutrient risk classification (loss_risk / retentive / responsive) - Carbon sequestration estimation (Hassink 1997 model with climate adjustment) - Soil x weather stress indicators combining AWC with water balance - Rosetta PTF integration for hydraulic property estimation - Soil-aware alerts for pH, SOC, compaction, waterlogging, sand, CEC - Soil summary in share reports - Map markers: bullseye sampling zones + circle scouting observations - Interactive popups with dark mode support - Tab-based marker visibility toggling - 6 new API endpoints, 2 Alembic migrations, ~100 i18n keys
1 parent 3210842 commit 11d95f1

24 files changed

Lines changed: 3855 additions & 87 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ docs/
4747

4848
# ── MinIO / Storage (local dev volumes) ──────────────────────────────
4949
minio-data/
50+
.agents/

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,51 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
88

99
---
1010

11+
## [0.8.0] - 2026-03-19
12+
13+
### Added
14+
- **Soil intelligence engine** — 2,200+ lines of agronomic logic in `core/soil_intelligence.py` powering crop suitability, nutrient analysis, carbon estimation, sampling recommendations, and stress monitoring.
15+
- **Crop suitability assessment** — 4-pillar weighted scoring system: Soil Fit (40%), Water Match (25%), Climate Fit (20%), Stress Resilience (15%) with 68 crop profiles spanning cereals, legumes, industrial crops, root/tuber, vegetables, fruits, plantations, and spices.
16+
- Weather-aware crop suitability — integrates annual rainfall, temperature range, drought/flood indices from `weather_daily`; requires ≥180 days of weather data.
17+
- `GET /fields/{id}/soil/crop-suitability` endpoint — returns top 10 most suitable crops with scores, ratings, and limiting factors; field's current crop type highlighted even if outside top 10.
18+
- **Sampling zone recommendations** — within-field soil variability analysis identifies locations where clay%, SOC, pH, or AWC differ most from field mean.
19+
- `GET /fields/{id}/soil/sampling-zones` endpoint — returns GeoJSON FeatureCollection with prioritized sampling points (P1–P3) and rationale.
20+
- **Nutrient risk classification** — classifies fields into nutrient_loss_risk, nutrient_retentive, or nutrient_responsive zones based on CEC, sand/clay, SOC, pH, and leaching risk.
21+
- `GET /fields/{id}/soil/nutrient-context` endpoint — returns zone classification with confidence score and agronomic interpretation.
22+
- **Carbon sequestration estimation** — Hassink (1997) clay-dependent protective capacity model with climate zone adjustment; estimates current SOC stock, saturation deficit, and sequestration potential range.
23+
- `GET /fields/{id}/soil/carbon-estimate` endpoint — returns current SOC stock, estimated saturation, and conservative sequestration potential (30–70% of deficit).
24+
- **Soil × weather stress indicators** — combines rootzone AWC with 30-day water balance, drought index, and soil moisture to detect drought/wet/optimal conditions.
25+
- `GET /fields/{id}/soil/weather-stress` endpoint — returns stress status with severity score (0–1) and contributing factors.
26+
- **Rosetta PTF integration** — pedotransfer functions estimate field capacity, wilting point, and saturated hydraulic conductivity from texture + bulk density on soil layers.
27+
- Derived agronomic columns on soil layers — `field_capacity`, `wilting_point`, `saturated_conductivity`, `awc_derived`.
28+
- SOC stock depth-integrated calculation (t/ha) in field summary.
29+
- Refined risk scoring — waterlogging risk from poor drainage + low Ksat; updated compaction and leaching formulas.
30+
- **Soil-aware alerts** — automatic alert generation on soil fetch for: pH < 5.5 (acidic), pH < 4.5 (very acidic), SOC < 10 g/kg (low), SOC < 5 g/kg (very low), compaction risk > 0.6, waterlogging risk > 0.6, sand > 80% (leaching), CEC < 5 cmol/kg (low retention).
31+
- `soil_context` JSONB column on alerts table — stores soil property values at alert creation time (same pattern as `weather_context`).
32+
- Soil alerts displayed in alert list with soil-specific icons, property values, and thresholds.
33+
- **Soil summary in share reports** — texture class, pH, SOC, CEC, drainage included in public share page report alongside weather summary.
34+
- `soil_summary` in `ShareReportOut` API schema.
35+
- Soil summary section on public share page with cards for texture, pH, organic carbon, CEC, AWC, drainage.
36+
- **Sampling zone map markers** — bullseye-style markers on MapLibre (outer ring + inner disc + center dot) with priority color coding (P1=red, P2=yellow, P3=blue).
37+
- **Scouting observation map markers** — amber circle markers with white stroke and observation detail popups.
38+
- **Interactive map popups** — CSS-based popup styling using shadcn design tokens (`--popover`, `--popover-foreground`, `--muted-foreground`) for dark mode compatibility.
39+
- Click-to-zoom on sampling zone sidebar cards — `flyTo` with zoom level 17.
40+
- Tab-based marker visibility toggling — scouting markers only visible on scouting tab, sampling markers only visible on soil tab.
41+
- Soil tab intelligence panels — crop suitability card with ranked list, nutrient context badges, carbon estimation gauge with sequestration range, weather stress traffic-light indicator, sampling zones sidebar.
42+
- Crop suitability weather-required info banner when weather data is insufficient.
43+
- Alembic migration `0012_add_derived_agronomic_columns` — field capacity, wilting point, saturated conductivity, AWC derived columns on soil layers.
44+
- Alembic migration `0013_add_soil_context_to_alerts``soil_context` JSONB column on alerts table.
45+
- English and Spanish translations for all intelligence UI strings (~100 i18n keys).
46+
47+
### Fixed
48+
- **Crop suitability sign convention** — drought severity now correctly uses `di < 0` for drought (was `di > 0`) in soil router; flood detection uses `drought_idx > 1.0` (was `< -1.0`) in intelligence engine.
49+
- Field's own crop suitability returned even when outside top 10 — endpoint now searches full list before truncating.
50+
- Race condition in field creation task dispatch — weather refresh and backfill tasks now dispatched after commit.
51+
- Rosetta-soil API compatibility — updated to work with rosetta-soil v0.3.x response format.
52+
- Popup title no longer overlaps close button — added `padding-right: 18px` to popup title CSS.
53+
54+
---
55+
1156
## [0.7.0] - 2026-03-19
1257

1358
### Added

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Open source self-hostable and reproducible Crop Intelligence Platform
4040
- Multi-index vegetation monitoring — NDVI, EVI, SAVI (configurable L factor), and NDWI from Sentinel-2 imagery with automatic 24-month historical backfill
4141
- ML-powered automatic field boundary detection (FTW model) with interactive review workflow
4242
- Daily weather data with agricultural indices (GDD, water balance, drought index) via Open-Meteo
43-
- Soil intelligence — automatic soil profile ingestion from SoilGrids (global, 250m) and POLARIS (US, 30m) with texture, pH, carbon, risk scoring, and interactive depth visualization
43+
- Soil intelligence — automatic soil profile ingestion from SoilGrids (global, 250m) and POLARIS (US, 30m) with crop suitability scoring (68 crops), sampling zone recommendations, carbon sequestration estimation, nutrient risk classification, and soil×weather stress monitoring
4444
- Reproducible pipeline with provenance (Element84 STAC → COG → TiTiler tiles)
4545
- Tenant isolation via `X-Org-Id` + JWT; RBAC (`owner`/`admin`/`member`/`viewer`)
4646
- MapLibre + PMTiles (no Mapbox token needed), ECharts for time series
@@ -171,17 +171,19 @@ ruff format --check .
171171
### Layer A — Observation
172172
- **Satellite Intelligence**: NDVI, EVI, SAVI (configurable L), NDWI from Sentinel-2 — STAC search → COG → TiTiler tiles → time-series stats, with automatic 24-month historical backfill and weekly auto-compute
173173
- **Weather Intelligence**: daily historical + 7-day forecast via Open-Meteo — temperature, precipitation, ET₀, soil moisture/temperature, VPD, GDD, water balance, drought index
174-
- **Soil Intelligence**: automatic soil profile from SoilGrids (global, 250m) and POLARIS (US, 30m) — texture-by-depth, pH, organic carbon, CEC, bulk density, AWC, risk scoring, data quality indicators
174+
- **Soil Intelligence**: automatic soil profile from SoilGrids (global, 250m) and POLARIS (US, 30m) — texture-by-depth, pH, organic carbon, CEC, bulk density, AWC, Rosetta PTF hydraulic properties, risk scoring, crop suitability (68 profiles, 4-pillar model), sampling zones, carbon estimation, nutrient context
175175
- **Boundary Detection**: ML-powered field boundary detection (FTW model) from Sentinel-2 — draw area, review with confidence scores, accept as fields
176176
- **Farms & Fields**: draw/upload GeoJSON/KML polygons, auto area calculation, soft delete
177177

178178
### Layer B — Intelligence
179179
- **Per-Index Alerts**: configurable threshold and drop-percentage rules, enriched with weather context and soil data
180-
- **Risk Scoring**: acidification, compaction, leaching, and rooting risk from soil properties
180+
- **Crop Suitability**: 4-pillar weighted scoring (Soil 40%, Water 25%, Climate 20%, Stress 15%) across 68 crop profiles with limiting factors
181+
- **Soil Intelligence**: nutrient risk zones, carbon sequestration potential, sampling zone recommendations, soil×weather stress indicators
182+
- **Risk Scoring**: acidification, compaction, leaching, waterlogging, and rooting risk from soil properties
181183
- **Multi-Signal Context**: alerts combine vegetation anomalies + weather conditions + soil characteristics
182184

183185
### Layer C — Delivery
184-
- **Interactive Map**: MapLibre + PMTiles (no Mapbox needed), multi-layer toggle, per-index colormaps
186+
- **Interactive Map**: MapLibre + PMTiles (no Mapbox needed), multi-layer toggle, per-index colormaps, scouting and sampling zone markers with interactive popups
185187
- **Time-Series Charts**: ECharts with percentile bands, NDVI + weather overlay, soil depth visualization
186188
- **Scouting**: geotagged observations with photo upload and auto-attached weather snapshot
187189
- **Sharing**: read-only field health reports via share links with multi-index, weather, and soil summary

0 commit comments

Comments
 (0)