Skip to content

Add interactive outlet picker (ArcSWAT-style) + example notebook#18

Merged
rehsani merged 1 commit into
mainfrom
interactive-outlet-picker
May 7, 2026
Merged

Add interactive outlet picker (ArcSWAT-style) + example notebook#18
rehsani merged 1 commit into
mainfrom
interactive-outlet-picker

Conversation

@rehsani
Copy link
Copy Markdown
Owner

@rehsani rehsani commented May 7, 2026

Summary

  • New floodpath.interactive module: leafmap-based outlet picker. Click any pixel in the DEM patch — it auto-snaps downstream to the nearest stream cell, delineates the upstream basin, and overlays it in green. Drag the outlet marker to fine-tune.
  • Returns an OutletSelection carrying the snapped outlet, basin, DEM, flow grid, and streams so the rest of the pipeline (compute_hand, routing, damage) chains off it without re-fetching.
  • Adds floodpath.hydrology.snap_to_stream as the public helper underneath; surfaces outside-DEM-bbox clicks as ValueError so GUI callers handle one branch.
  • Adds examples/pick_outlet.ipynb walking the full DEM → flow → streams → outlet → HAND → flood → population → damage chain at Kigali, Rwanda.
  • Optional dep: pip install floodpath[interactive] (leafmap, ipyleaflet, matplotlib).

Test plan

  • pytest -m "not integration" passes (343 tests, +3 snap + 8 interactive vs. baseline)
  • Smoke-run end-to-end at Kigali defaults: DEM fetch, flow accumulation, stream extraction, picker construction, snap, basin delineation, HAND, flood at 5 m water level, WorldPop fetch (RWA), GHSL fetch + JRC damage curve all return sensible outputs
  • Manual map test in Jupyter: click → snap → basin overlay; drag marker → re-snap; outside-domain click silently ignored

…tebook

New floodpath.interactive module with a leafmap-based outlet picker:
- pick_outlet(lat, lon, ...) returns an OutletPicker showing a grayscale
  hillshade + Strahler-styled stream network on a CartoDB.Positron basemap
- Each click is auto-snapped downstream to the nearest stream cell via
  pyflwdir, the upstream basin is delineated and overlaid in green
- Draggable outlet marker for fine adjustment; drops re-snap and
  re-delineate in place
- OutletSelection bundles outlet, basin, DEM, flow grid, streams so
  downstream pipeline stages can chain off it without re-fetching

Adds floodpath.hydrology.snap_to_stream as the public helper underneath
the picker (also surfaces outside-DEM-bbox clicks as ValueError so GUI
callers handle one branch).

Adds examples/pick_outlet.ipynb walking the full DEM -> flow -> streams
-> outlet -> HAND -> flood -> population -> damage chain at Kigali,
Rwanda.

Optional dep: pip install floodpath[interactive] (adds leafmap,
ipyleaflet, matplotlib).

Tests: 343 offline tests pass (3 new snap + 8 new interactive).
@rehsani rehsani merged commit 6000f75 into main May 7, 2026
1 check failed
@rehsani rehsani deleted the interactive-outlet-picker branch May 7, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant