Skip to contents

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

  1. UM: upstream mainstem

  2. DM: downstream main

  3. UT: upstream with tributaries

  4. DD: downstream with diversions

distance

numeric distance in km to limit navigation. The first catchment that exceeds the provided distance is included.

Value

vector of identifiers found along navigation

Details

if only mode is supplied, require network attributes are displayed.

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)