How reneilwekeoagile061/landsat-water-analysis-ai works
Purpose and Entry Points
This is an offline geospatial ML pipeline plus static Vite/Leaflet dashboard for screening surface-water and groundwater-investigation potential in Botswana. The pipeline’s main interactive entry is CET313_Artificial_Intelligence_Prototype (1).ipynb; scriptable preparation begins in scripts/export_frontend_data.py. The browser application starts at index.html and src/main.js.
1. Scene Acquisition and Source Boundaries
Landsat 8/9 and optional Sentinel-1 metadata are queried from Microsoft Planetary Computer STAC by scripts/fetch_stac_catalog.py, producing cached catalogs such as data/landsat_stac.json and data/sentinel1_stac.json. This external-service boundary supplies metadata/assets, not browser-live data. Soil clay enrichment is separately requested from ISRIC SoilGrids by scripts/fetch_soilgrids.py.
2. Geospatial Feature Preparation
Notebook and reusable Python modules transform satellite and terrain inputs into water-relevant features: spectral indices in scripts/indices.py and elevation/slope in scripts/dem_features.py. The primary flow is scene/pixel data → NDWI/MNDWI and related features → prediction-ready tabular rows. AOIs and coordinates define the spatial partitioning rather than a server-side spatial database.
3. Labeling, Training, and Scientific Guardrails
scripts/labeling.py creates composite/K-Means-derived water-potential labels; scripts/train_water_potential.py trains and spatially validates classifiers, including holdout-region handling. scripts/validate_labels.py evaluates agreement with independent rules. Model classes are Low/Medium/High, but the repository explicitly frames results as screening because checked-in hydrogeology may be synthetic demonstration data.
4. Subsurface Screening and Evidence Model
scripts/subsurface_metrics.py derives depth-to-water categories, phreatophyte indicators, shallow-clay infiltration proxies, feasibility signals, and evidence/validation fields. scripts/fetch_soilgrids.py can replace some synthetic inputs with externally modeled clay observations. The key boundary is evidence provenance: exported properties distinguish measured, modeled, screening, and synthetic demonstration values; the UI should support investigation prioritization, not drilling guarantees.
5. Export Contract and Static Data Delivery
scripts/export_frontend_data.py converts notebook prediction CSVs into the frontend contract: data/exports/water_points.geojson, data/exports/aois.geojson, data/exports/scenes.json, and data/exports/metrics.json. Deployable copies reside under public/data/exports/. This is the central handoff between Python processing and the browser; no backend API or runtime job system exists.
6. Browser Data, State, and Validation
src/api/loadData.js fetches the four static resources and src/api/schema.js validates their shapes with Zod before rendering. src/state/filters.js applies AOI, season, tier, cloud, and confidence filtering as client-side pure state logic. src/main.js coordinates loading, filter application, UI refresh, and map updates.
7. Mapping and Decision-Support UI
src/map/mapController.js owns Leaflet map lifecycle, AOI overlays, heatmaps, classified points, subsurface layers, popups, drawing, and property-level aggregation. src/ui/dashboard.js renders dashboard content, while src/ui/tabs.js controls panel visibility. Control flow is static export fetch → schema validation → filter state → map/dashboard rendering; interactions can recalculate local property and water-capture planning summaries without persisting data.
Runtime and Deployment
Python 3.10+ supports Jupyter, geospatial processing, scikit-learn/XGBoost, STAC, and SoilGrids clients. Node.js 18+, Vite, vanilla JavaScript, Leaflet/Leaflet.heat, and Zod build and serve the static frontend via vite.config.js. vercel.json supports static deployment; .github/workflows/ci.yml provides CI. Production deployment must include the public export files and does not require application-server infrastructure.
Main entry points: train_water_potential.py Spatial model training · main.js Application coordinator · export_frontend_data.py Frontend export builder · subsurface_metrics.py Subsurface evidence metrics
Components 22
External Sources
- Planetary Computer STAC · Landsat and optional Sentinel-1 metadata and assets.
- ISRIC SoilGrids · Modeled clay observations.
Python Screening Pipeline
- STAC catalog fetch
scripts/fetch_stac_catalog.py - SoilGrids fetch
scripts/fetch_soilgrids.py - Cached scene catalogs
data/landsat_stac.json - Water feature preparation · Produces spectral and terrain features for prediction rows.
scripts/indices.py - Terrain features · Elevation and slope enrichment.
scripts/dem_features.py - Potential labeling · Composite and K-Means-derived water-potential labels.
scripts/labeling.py - Spatial model training · Spatial holdout validation produces Low, Medium, and High screening predictions.
scripts/train_water_potential.py - Independent label checks
scripts/validate_labels.py - Subsurface evidence metrics · Adds depth, clay, feasibility, and provenance fields.
scripts/subsurface_metrics.py - Interactive analysis · Interactive pipeline entry point.
CET313_Artificial_Intelligence_Prototype (1).ipynb
Static Export Contract
- Frontend export builder · Central Python-to-browser handoff.
scripts/export_frontend_data.py - GeoJSON and metrics exports · Water points, AOIs, scenes, and metrics.
data/exports/water_points.geojson - Deployable public exports · Copies served with the dashboard.
Vite / Leaflet Dashboard
- Static data loader and schemas · Fetches and Zod-validates the four export resources.
src/api/loadData.js - Client filter state · AOI, season, tier, cloud, and confidence filtering.
src/state/filters.js - Application coordinator · Coordinates loading, filtering, and rendering.
src/main.js - Leaflet map controller · Renders AOIs, points, heatmaps, subsurface layers, and local summaries.
src/map/mapController.js - Dashboard panels
src/ui/dashboard.js - Panel tabs
src/ui/tabs.js - Static Vite site · No application server or runtime jobs.
index.html
Connections 22
- Planetary Computer STAC → STAC catalog fetch: catalog query
- STAC catalog fetch → Cached scene catalogs: cache metadata
- Cached scene catalogs → Water feature preparation: scene inputs
- ISRIC SoilGrids → SoilGrids fetch: clay request
- Water feature preparation → Potential labeling: prediction rows
- Terrain features → Spatial model training: terrain inputs
- Potential labeling → Spatial model training: training labels
- Spatial model training → Independent label checks: predictions
- Spatial model training → Subsurface evidence metrics: screening points
- SoilGrids fetch → Subsurface evidence metrics: modeled clay
- Subsurface evidence metrics → Frontend export builder: evidence and provenance
- Spatial model training → Frontend export builder: classified predictions
- Interactive analysis → Frontend export builder: prediction CSVs
- Frontend export builder → GeoJSON and metrics exports: generate
- GeoJSON and metrics exports → Deployable public exports: deploy copies
- Deployable public exports → Static data loader and schemas: static fetch
- Static data loader and schemas → Application coordinator: validated data
- Client filter state → Application coordinator: filter results
- Application coordinator → Leaflet map controller: map updates
- Application coordinator → Dashboard panels: dashboard refresh
- Panel tabs → Dashboard panels: panel visibility
- Static Vite site → Application coordinator: browser startup