Navigates a network of connected catchments using NHDPlus style network attributes.
Usage
navigate_hydro_network(x, start, mode, distance = NULL)
# S3 method for data.frame
navigate_hydro_network(x, start, mode, distance = NULL)
# S3 method for hy
navigate_hydro_network(x, start, mode, distance = NULL)
Arguments
- x
data.frame network compatible with hydroloom_names.
- start
character or numeric to match identifier attribute. The starting catchment is included.
- mode
character chosen from c(UM, DM, UT, or DD).
UM: upstream mainstem
DM: downstream main
UT: upstream with tributaries
DD: downstream with diversions
- distance
numeric distance in km to limit navigation. The first catchment that exceeds the provided distance is included.
Details
if only mode
is supplied, require network attributes are displayed.
NOTE: for "Upstream with tributaries" navigation, if a tributary emanates from a diversion and is the minor path downstream of that diversion, it will be included. This can have a very large impact when a diversion between two large river systems. To strictly follow the dendritic network, set the "dn_minor_topo_sort" attribute to all 0 in x.
Examples
plot_fun <- function(x, s, n) {
plot(sf::st_geometry(x), col = "grey")
plot(sf::st_geometry(x[x$id %in% n, ]), add = TRUE)
plot(sf::st_geometry(x[x$id %in% s, ]), col = "red", lwd = 3, add = TRUE)
}
x <- hy(sf::read_sf(system.file("extdata/new_hope.gpkg", package = "hydroloom")))
start <- 8891126
dm <- navigate_hydro_network(x, start, "DM")
plot_fun(x, start, dm)
dd <- navigate_hydro_network(x, start, "DD")
plot_fun(x, start, dd)
start <- 8894356
um <- navigate_hydro_network(x, start, "UM")
plot_fun(x, start, um)
ut <- navigate_hydro_network(x, start, "UT")
plot_fun(x, start, ut)