DOI-USGS / hyRefactor

https://code.usgs.gov/wma/nhgf/reference-fabric/hyrefactor
Creative Commons Zero v1.0 Universal
5 stars 0 forks source link

Area-based aggregation. #15

Open dblodgett-usgs opened 3 years ago

dblodgett-usgs commented 3 years ago

We need a way to aggregate catchments using an area target in addition to points of interest. Under the covers, this would likely just add additional points of interest where catchments are larger than the target.

I could see adding a "max area" and "max length" input that would get handled here: https://github.com/dblodgett-usgs/hyRefactor/blob/be7d2fc3b19fa79f7555e7f47106c91b8dbaa5ce/R/aggregate_catchments.R#L379

Or possibly just after that make_outlets_valid() finishes so we have a clean minimal network to start with.

The implementation might be tricky, but I think it could be not too bad if done artfully. We would have to look at the difference in drainage area for the inlet and outlet of every to-be-created catchment based on the initial minimal network. We would then split each too large catchment into pieces -- only allowing splits at nexuses from the provided network -- such that the resulting pieces have the desired drainage area.

An issue that will crop up when a given nexus has more than one contributing catchment. Care would need to be taken to determine if all contributing catchments to a nexus are combined or not - if not, they may need to be resolved separately.

These two parameters to aggregate catchments help describe that last comment.

#' @param da_thresh numeric Defaults to NA. A threshold total drainage area in the
#' units of the TotDASqKM
#' field of the flowpath data.frame. When automatically adding confluences to make
#' the network valid, tributary catchments under this threshold will be lumped with
#' the larger tributaries rather than being added to the set of output catchments.
#' @param only_larger boolean Defaults to TRUE. If TRUE when adding confluences to
#' make the network valid, only tributaries larger than the one with an upstream
#' outlet will be added. e.g. if a tributary is required in the model this will
#' add main stems that the tributary contributes to. Note that the NHDPlus treats
#' divergences as part of the main stem, so the da_thresh may still be needed to
#' eliminate small tributary catchments introduced by divergences near confluences.