Use MATLAB stats and new GS attributes in /arctic_hydrology/stats/ endpoint#723
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Arctic hydrology API to use the new Rasdaman MHIT statistics coverage and updated GeoServer attributes, and to populate a summary block from a dedicated WFS stats layer for frontend “data sentences”.
Changes:
- Switch
/arctic_hydrology/stats/<stream_id>to the newak_hydro_segments_mhit_stats_combinedRasdaman coverage to expose the full MHIT statistics suite. - Add a new WFS URL generator + request path to fetch precomputed “summary” statistics from
hydrology:arctic_rivers_segments_stats_simplified, and include additional segment metadata (e.g., gauge/watershed attributes). - Expand Arctic hydrology documentation and CSV header metadata to reflect the broader stats set and new
?source=options.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
templates/documentation/arctic_hydrology.html |
Updates endpoint docs, query params (?source=), and example responses to reflect the new stats/summary/metadata. |
routes/arctic_hydrology.py |
Switches the stats coverage, adds WFS summary fetch + response population, and adds new segment metadata fields. |
generate_urls.py |
Updates Arctic hydrology WFS layer name/attributes and adds a new WFS URL builder for summary stats. |
csv_functions.py |
Updates Arctic stats CSV header comments to enumerate the expanded MHIT statistic set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cstephen
left a comment
There was a problem hiding this comment.
This all looks great to me!
To test this PR, I went ahead and incorporated all of the new Alaska/Canada stream stats into the hydroviz webapp (ua-snap/hydroviz#193) to see if anything was missing. Everything is accounted for ✔️ The Alaska portions of the webapp now act exactly like their CONUS counterparts, including a watershed-based choropleth, clickable watersheds that zoom into stream segments with outlets highlighted red, searchable watersheds and stream segments using the search bar, and all data sentences/charts/tables populated properly.
I also gave the revamped endpoint documentation a careful look, tried downloading CSVs files using different source parameters, and inspected the CSV metadata, and everything looks perfect. 👍
This branch upgrades the Arctic hydrology endpoints to use updated GeoServer layer attributes and the new Rasdaman coverage that expose the full MHIT statistics suite. This branch also populates the
summaryblock of pre-computed key statistics for use by the front end data sentences.Summary of changes
All MHIT statistics: The stats endpoint (
/arctic_hydrology/stats/<stream_id>) now returns all 50+ MHIT hydrologic statistics via the newak_hydro_segments_mhit_stats_combinedRasdaman coverage. Previously only ma12–ma23 and ma99 were returned.summaryblock on stats and hydroviz endpoints: The top-levelsummarykey is populated from thearctic_rivers_segments_stats_simplifiedGeoServer layer which provides pre-computed statistics for the data sentences section of the app. Previously, there was a placeholder stub dictionary here populated with null values.Additional segment metadata: Stats and climatology responses now include
gauge_id(USGS or Canadian gauge ID if available, empty string otherwise),watershed(HUC8 or Yukon watershed ID), andwatershed_outlet(boolean). Note that the dictionary keys here vary from the CONUS return because we aren't dealing exclusively with HUC8s in the transboundary dataset.GeoServer layer updates
generate_wfs_arctic_hydrology_url: Updated WFS layer name fromhydrology:arctic_segmentstohydrology:arctic_rivers_segments_joined_3338_simplifiedand expandedpropertyNameto includeGauge_ID,ID_1,ID_2,Name, andoutlet.generate_wfs_arctic_hydrology_stats_url(new): Fetches pre-computed summary statistics fromhydrology:arctic_rivers_segments_stats_simplified.Documentation (
arctic_hydrology.html)?source=parameter documentation to both endpoint tables (stats: three accepted values; modeled climatology: two accepted values), matching the CONUS hydrology docs.summary,watershed,watershed_outlet, andgauge_idfields.CSV output (
csv_functions.py)arctic_hydrology_csv()to document all 50 statistics with descriptions matching the format used by the CONUS hydrology CSV.