Skip to content

Methodology

How AquaLens reads water from space.

AquaLens runs two linked pipelines. The deterministic numeric core pulls a fresh Sentinel-2 scene, computes six band-math indices over the water mask, and produces a 0–100 risk score that is unit-tested and never moved by the LLM. The Gemini agent layer wraps that core with five specialist agents that choose inputs, gather grounded context, write the brief, and publish a citizen-facing summary. Every step is reproducible and recorded.

Imagery acquisition

We query the Microsoft Planetary Computer STAC API for thesentinel-2-l2acollection, intersected with the polygon and filtered byeo:cloud_cover < threshold. The most recent matching scene is selected, the asset URLs are signed, and the relevant bands (B02 · B03 · B04 · B05 · B08 · B11) are streamed as Cloud-Optimized GeoTIFFs and clipped to the AOI.

Spectral indices

Each index is a pure numpy function over the band stack. We mask non-water pixels using NDWI > 0, then aggregate to a masked-mean per index.

Normalized Difference Water Index

NDWI

bands · B08 · B11

(NIR − SWIR) / (NIR + SWIR)

Open-water signal. Values above zero indicate water cover.

Modified NDWI

MNDWI

bands · B03 · B11

(Green − SWIR) / (Green + SWIR)

Water signal that holds up in urban / built-up settings.

Normalized Difference Turbidity

NDTI

bands · B04 · B03

(Red − Green) / (Red + Green)

Higher values indicate more turbid water columns.

Normalized Difference Chlorophyll

NDCI

bands · B05 · B04

(RedEdge − Red) / (RedEdge + Red)

Proxy for chlorophyll-a, a bloom precursor.

Normalized Difference Vegetation

NDVI

bands · B08 · B04

(NIR − Red) / (NIR + Red)

Shoreline vegetation health; useful as a stress co-signal.

Water Ratio Index

WRI

bands · B03 · B04 · B08 · B11

(Green + Red) / (NIR + SWIR)

Strong open-water signature when values exceed 2.5.

Risk model

The numeric score is deterministic and audit-friendly. Each contributing factor is normalized into [0, 1] and multiplied by its weight. Field-evidence flags then add a bonus up to 0.5, and the result is clamped.

Weights

NDCI (chlorophyll proxy)
0.40
NDTI (turbidity)
0.25
NDVI shoreline stress
0.10
MNDWI water-signal floor
0.10
NDWI water-signal floor
0.15

Levels bucket at < 0.33 (low) and < 0.66 (medium); the rest is high. Urgency is a function of the level plus severity of the latest evidence (algae presence, dead-fish count, complaints).

Agentic hand-over

Once deterministic scoring is complete, the runtime hands the session bundle to the agent layer. Agents can pick inputs, gather context, and write prose, but they cannot override the deterministic level or urgency. Each agent is a focused Gemini call constrained by a domain-specific system prompt and a structured-output contract that forbids overclaiming.

Multi-agent workflow

When a session runs, a small graph of specialised Gemini agents plans the work, gathers context, drafts the brief, and turns it into a citizen-facing summary. Agent colour and action-label wording match the in-app Agentic workflow card so the marketing surface and the live trace describe exactly the same thing.

  1. Coordinator · plans the workflow

    Agent 1

    Gemini thinking mode

    Reads the AOI + history and decides per-agent budgets. Always schedules Scout, Analyst, and Reporter for water AOIs; schedules Historian when prior sessions exist.

  2. Scout · picks the satellite scene

    Agent 2

    Function calling + Gemini Vision

    Calls Planetary Computer for Sentinel-2 candidates, then asks Gemini Vision to look at the actual RGB thumbnail. If the freshest scene is hazy over the AOI, the Scout re-queries with a tighter cloud bound.

  3. Historian · pulls trends and grounded context

    Agent 3

    History + Search grounding + memory

    Reads prior sessions, runs a Mann-Kendall significance test in Gemini's Python sandbox, cites real local news via Google Search grounding + URL Context, and writes a distilled note back to per-water-body memory (text-embedding-004 + pgvector) for next time.

  4. Analyst · writes and self-critiques the brief

    Agent 4

    Structured output + critique loop

    Drafts recommendation + reasoning + limitations against the deterministic numbers. A separate Gemini call critiques the draft against the hard rules (cites two indices, names a real limitation, no overclaiming). If anything fails the Analyst rewrites once. Both drafts land in the trace.

  5. Reporter · writes the citizen summary

    Agent 5

    Structured response schema

    Turns the deterministic numbers + Scout / Historian / Analyst outputs into the public-facing card: likely-safe · use caution · avoid tone, guidance for adults and for pets and kids, explicit limitations, and citations when grounded context exists. Falls back to a deterministic summary if the call fails.

Every step is captured in a per-session trace (the Agent decisions card on the session page). Failed agents leave the failure in the trace and the pipeline falls back to a deterministic path — Reporter falls back to a deterministic citizen summary, Analyst falls back to a deterministic narrator — so every session produces a usable brief.