Inspiration

Caño Negro, a protected wetland in northern Costa Rica, is drying out. The refuge's lagoon, about 800 ha in the wet season, nearly empties every dry season (SINAC), and some of the land around it is being drained by canals for pineapple and cattle; Costa Rica's environmental tribunal has investigated 19 cases.

The people who live there have had to prove it by plane: a local association has been sending aerial photos to SINAC to show the water shrinking. Normal satellites can't help, because clouds cover the area most of the year and much of the water sits under trees and floating grass.

NASA-ISRO's new NISAR radar sees through cloud and partly under vegetation, and it passes over Caño Negro about every 6 days. We built Town Lens to turn each pass into a checked measurement, say it in plain Spanish to the people who live there, and send the people who can go and look (rangers, the drinking-water operator, brigades) to check it on the ground.

What it does

One radar, three kinds of user, the same numbers.

  • Residents (/hoy and the native iPhone app): the wetland right now, like a weather app. One sentence ("La laguna tiene casi la mitad del agua que suele tener en noviembre"), today's word for each activity, the weather, the season ahead, read aloud, ask out loud, and report what they see.
  • SINAC, municipalities and researchers (/tech and /map): every NISAR pass (25 so far, 21 June to 24 November 2026), checked against NASA OPERA; the latest pass is 295 ha open water + 72 ha under vegetation, −53% against the November normal, and −58% for UN SDG 6.6.1 against November 2024. Plus a time machine, projections, at-risk places, a drinking-water risk map and a dated PDF report.
  • The field office (/login, /ops, /campo, and crew mode in the iPhone app): Town Lens ends many answers with "needs checking on the ground". The field office turns those into jobs for the crew and brings what they find back into the record.

Fit with the UN goals (Track 1)

  • 6.6.1, change in the extent of water-related ecosystems over time: exactly what Town Lens measures, every pass, against a baseline.
  • 6.4 water scarcity (today against the month's normal, the trend, the season ahead), 6.3 water quality (a turbidity signal on clear Sentinel-2 days), 6.1 drinking water (risk factors at 261 places, and lab results from the field office), and 6.b community participation (Spanish first, read aloud, field reports compared with the radar, a report the community can take to SINAC).
  • 6.5 managing water together (one shared record for SINAC, the water association and farmers, and the same method for cross-border wetlands like Lake Titicaca and the Pantanal), and indirectly 6.2 sanitation (homes that flood or sit on low ground, where latrines and septic tanks can leak into wells, are flagged for checks) and 6.a support for developing countries (free NASA and ISRO radar turned into a tool Latin American agencies can run, in Spanish). That covers all eight SDG 6 targets.
  • It scales: eight more wetlands across the Americas are measured the same way, and any area in the Americas can be drawn and measured with NISAR.

Inside the field office

The board. The refuge office's board at /ops shows the whole operation at a glance: residents' requests, jobs by stage (to approve, unassigned, offered, scheduled, in the field, to review, closed) with a workflow chart and live counts, estimates to approve, today's crew, the week with the weather and boat access, equipment running low, communities, the latest activity, and the ground against the radar.

Jobs. Each job shows what to check, where it is and how to get there (boat, road or foot; this pass's water map says whether a boat can reach it), the kit and materials, the duration and start hour, the estimate, who should go and why, the full timeline and the report.

Crew and equipment. Crew have skills and certifications (boat operator, water sampling, chainsaw…), shifts and working days, a base, a live status (available, on the way, on site, off) and their offered and assigned jobs. Boats, vehicles, kits, consumables and safety gear each have a quantity, minimum, unit, status (ok or in maintenance), notes and rates; consumables come off the shelf when a job closes, and anything below its minimum shows as needing restocking.

Three roles, three views. The coordinator's board at /ops, with accounts and roles; the field crew at /campo; and residents at /hoy/requests, who follow their request from received to the office's answer. Roles are checked on the server for every request: a ranger sees only jobs offered or assigned to them, a resident only their own requests. Sessions are random tokens in an HttpOnly cookie.

On the phone. The native iPhone app has a crew mode: offers arrive with Acepto / No puedo (with a reason the office sees), today's jobs in route order with the start hour, Cómo llegar, "on my way" and "on site", the job's questions as a checklist, and the report: outcome, measurements, materials used, notes, photos and voice notes. Every update goes into the job's event log and timeline; the office reviews and closes it, and the answer goes back to the resident who asked. Reports made without signal wait in an outbox on the phone and send themselves. A mobile web view at /campo does the same in the browser.

Weather. Open-Meteo forecasts on the residents' Today page and in the app (hourly temperature, rain chance and wind), and the week planner uses them: boats stay in on thunderstorm or windy days (over 30 km/h) and hot days start at 6.

Voice. Rangers on a boat tap "Contar por voz" and talk; Gemini transcribes the note and fills in the report (outcome, measurements, materials used, summary), each field marked as AI-filled for the ranger to check. Residents can send requests as voice notes. "Ask Town Lens" / "Pregunte" takes a spoken question (browser or Apple speech recognition) and answers only from today's data, read aloud in a natural Gemini voice; on the iPhone, "Escuchar" uses recorded offline Piper voices, so it works with no signal.

Lab sheets. Upload a photo or PDF of a drinking-water analysis and Gemini reads the lab, date, sampling point and every value as printed; Town Lens then checks them against Costa Rica's limits (Decreto 38924-S: E. coli not detectable, turbidity alert 1 and maximum 5 NTU, free chlorine 0.3–0.6 mg/L). The result is saved as a water test linked to the scanned sheet and becomes a point on the drinking-water risk map.

AI where it saves real minutes. A person confirms everything: a ranger talks instead of typing a report, a lab sheet is read in instead of typed value by value, and a resident's words become a one-line summary in Spanish and English, with an urgent flag only when health or safety is at risk. Without AI, Ask Town Lens falls back to the written guide.

By hand first, then automated. Every step works by hand; on top of that:

  • every resident request becomes a costed draft job, the drinking-water risk map's 21 medium and high places become test jobs in one click, and radar flags become ground checks;
  • who should go is ranked by the skills the job needs, working days, distance from base and the week's load, with the reasons shown;
  • "Plan the week" fits open jobs into shifts using the weather, boat access from this pass's water map, the one working boat and the nearest-stop order, and proposes it with reasons for the office to apply;
  • approve, offer, close or cancel many jobs at once;
  • a GitHub Action checks NASA's catalogue every 6 hours, measures new passes, commits the data and redeploys.

Seeing the work. The board's workflow chart, the week planner as a calendar and in 3D (three.js), the flow from a radar pass to a phone in the village with live counts at every step, the chart of every pass against the normal range, a 3D model of the refuge, and the lagoon on a table in AR in the iPhone app, filling and emptying across the year.

Risk, stated carefully. Drinking-water risk factors at 261 mapped homes and places (labelled as factors, not tests), at-risk zones that are losing water, possible-drainage flags that always say "needs checking on the ground", and boat access per job from the latest water map. The AI withholds any answer that calls the water safe or gives a depth.

Your data stays local. Postgres, with tables for users, sessions, crew, resources, requests, jobs, job_events (every change to every job, in order), attachments, water tests and settings. docker compose up runs Postgres next to the site, so a refuge office keeps residents' reports, home locations and lab results on its own machine. Without a database, the same schema runs on PGlite (Postgres in WebAssembly).

Try it

  • Live: https://town-lens.vercel.app. The login page at /login has three demo buttons: the refuge office (coordinator), a ranger (field crew) and a resident. The iPhone app has "Entrar como guardaparques (demo)" and "Entrar como residente (demo)".
  • Run it yourself: docker compose up, then open localhost:5173. Every measured pass is bundled, so nothing needs a key; Postgres starts and the demo accounts are seeded. Without Docker, npm ci && npm run dev works with a local PGlite database. .env.example lists the optional keys, and the README has a table of every variable, where it goes and whether it's free.

How we built it

  • Pipeline (Python 3.11): find every NISAR L2 GCOV pass in NASA's CMR catalogue → read only the refuge's pixels over HTTPS → Lee speckle filter → Otsu threshold for open water (clamped to −24 to −14 dB), plus bright HH with a large HH−HV difference for water under vegetation → count hectares inside the OpenStreetMap refuge outline.
  • The check: each pass is compared with the nearest NASA OPERA DSWx-S1 map within 3 days. Agreement is F1 0.68–0.89, where $$F_1 = \frac{2PR}{P+R}$$ for precision \( P \) and recall \( R \) of our water pixels against OPERA's. Where they disagree, the site shows no number at all.
  • Normal and history: the same month's range from OPERA monthly maps since 2024; the long record from JRC Global Surface Water (1984–2021).
  • Website: React 18, TypeScript, Vite, Tailwind CSS 4, MapLibre GL and three.js, on Vercel with one function for the AI.
  • Field office: Postgres (Docker, Neon, or PGlite), postgres.js, cookie sessions with roles.
  • iPhone app: SwiftUI, Swift Charts, SwiftData, MapKit, RealityKit/ARKit, WidgetKit, App Intents, Speech, and offline Piper voices.
  • AI: Google Gemini through an OpenAI-compatible endpoint and Gemini TTS, on a Vercel Function.
  • Tests and CI: 95 commits; the website runs lint, types and Vitest (npm run check), the pipeline pytest, ruff and mypy, and the iPhone app 20 app and UI tests that tap through every screen, plus field-office UI tests against a seeded server. CI runs on every push.

Challenges we ran into

  • Trust. Radar water maps can be wrong, so a pass that disagrees with NASA OPERA gets no number rather than a wrong one, and every screen says what Town Lens can't do: radar doesn't measure depth, possible drainage needs checking on the ground, and the outlook comes from past seasons, not a forecast.
  • Water under vegetation. Much of Caño Negro's water hides under trees and floating grass, so there's a separate HH/HV rule for flooded vegetation next to the open-water threshold.
  • No signal in the field. A ranger on the lagoon may have no signal, so reports wait in an outbox on the phone and send themselves later.
  • AI that doesn't make things up. The AI only rephrases our numbers, every AI-filled field is marked for a person to check, and silent or sub-second voice notes are not sent, because given silence the model can invent a report.

Accomplishments that we're proud of

  • 25 real NISAR passes measured and checked, not mock data.
  • The same measurement reaches a resident's phone in plain Spanish, a ranger's job list, and SINAC as a dated, sourced SDG 6.6.1 record.
  • A full loop with the ground: residents' reports and rangers' checks are compared with the radar and go back into the record.

What's next for Town Lens

  • Watching Caño Negro through the dry season, which starts in January.
  • Real push alerts, shared field reports, and more communities.
  • The daily guide stays free for residents; organizations pay for the technical side and the field office (SINAC, conservation programs, Costa Rica's payments for ecosystem services, restoration projects).

Built by Anuj, Suad, and Tamir with open data from NASA, ESA, the EC JRC and OpenStreetMap. Code started Friday 27 November 2026 at about 5:40 PM; SAR-Pulse was inspiration only, no code reused. The field office's people are invented for the demo; the places, radar flags and drinking-water risk map are Town Lens's own. Town Lens is a planning aid and doesn't replace official notices.

Built With

Share this project:

Updates

Submission history