
Snap HYDAT stations to FWA fundamental watersheds, checked by drainage area
Source:R/wet_station_snap.R
wet_station_snap.RdFinds the num_features nearest stream segments to each station with
fwapg's fwa_indexpoint() (the function fresh::frs_point_snap() wraps),
in one query for all stations, and keeps the candidate whose upstream area
is closest to HYDAT's gross drainage area on a log scale. The nearest
segment at a confluence is often the wrong stream, and the area is what
tells them apart. A snap is accepted when that area is within max_dev of
the gross drainage area.
Usage
wet_station_snap(
conn,
stations,
tolerance = 1000,
num_features = 5,
max_dev = 0.1,
lake_dist = 3000,
lake_min_ha = 100,
lake_min_share = 0.5
)Arguments
- conn
A DBI connection to an fwapg database.
- stations
data.frame(station_number, lon, lat, drainage_area_gross_km2), e.g. fromwet_station_select().- tolerance
Search distance, m.
- num_features
Candidates per station.
- max_dev
Accepted relative deviation of the snapped area from the gross drainage area.
A station is flagged as a lake outlet when a lake of at least
lake_min_hahectares lies withinlake_distmetres of the gauge, has stream segments upstream of the snapped point on the FWA network (fwa_upstream()), and drains betweenlake_min_shareand1 + max_devof the gauge's upstream area. So an inlet, an off-network pond, or a lake on a tributary is not one; the upper bound also catches an inlet that an FWA coding fault places upstream.