get_minimal_network: Get Minimal Network

get_minimal_networkR Documentation

Get Minimal Network

Description

Given a set of outlets, will generate a minimal network by calling aggregate_network and adding nhdplus attributes to the result.

If geometry is included with the network, it will be merged and returned.

Usage

get_minimal_network(flowpath, outlets)

Arguments

flowpath

sf data.frame Flowpaths with ID, toID, LevelPathID, Hydroseq and LENGTHKM and AreaSqKM attributes.

outlets

data.frame with "ID" and "type" columns. "ID" must be identifiers from fowpath and divide data.frames. "type" should be "outlet", or "terminal". "outlet" will include the specified ID. "terminal" will be treated as a terminal node with nothing downstream.

Value

a data.frame (potentially including an sfc list column) with attributes generated by add_plus_network_attributes and a list column "set" containing members of each output flowpath.

Examples

source(system.file("extdata", "walker_data.R", package = "nhdplusTools"))
fline <- walker_flowline

outlets <- data.frame(ID = c(5329357, 5329317, 5329365, 5329435, 5329817),
                      type = c("outlet", "outlet", "outlet", "outlet", "outlet"))

#' Add toCOMID
fline <- nhdplusTools::get_tocomid(fline, add = TRUE)

# get attributes set
fline <- dplyr::select(fline, ID = comid, toID = tocomid,
                       LevelPathID = levelpathi, hydroseq = hydroseq,
                       AreaSqKM = areasqkm, LENGTHKM = lengthkm)

min_net <- get_minimal_network(fline, outlets)

plot(sf::st_geometry(fline), col = "blue")
plot(sf::st_geometry(min_net), lwd = 2, add = TRUE)
plot(sf::st_geometry(nhdplusTools::get_node(min_net)), add = TRUE)


dblodgett-usgs/hyRefactor documentation built on Oct. 14, 2024, 12:59 p.m.