DOI-USGS / DOI-USGS/hyRefactor

Area-based aggregation.

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
5
Forks
1
PR merge metrics
No merged PRs in 30d

Description

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.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Read R/aggregate_catchments.R around line 379 and trace make_outlets_valid() to understand where area-based inputs could be handled. Define how max area and max length should split oversized catchments only at provided-network nexuses, including cases with multiple contributing catchments; done means resulting pieces meet the target while respecting da_thresh and only_larger behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.