leaf_reaches: Return leaf reaches from a network or query intersecting lake

View source: R/network.R

leaf_reachesR Documentation

Return leaf reaches from a network or query intersecting lake

Description

A leaf reach is a stream flowline that has upstream connections but is not in the focal set.

Usage

leaf_reaches(
  lon = NA,
  lat = NA,
  network = NA,
  approve_all_dl = FALSE,
  temporary = TRUE,
  ...
)

Arguments

lon

numeric decimal degree longitude. optional. See Details section.

lat

numeric decimal degree latitude. optional. See Details section.

network

sf lines collection. optional. See Details section.

approve_all_dl

logical blanket approval to download all missing data. Defaults to TRUE if session is non-interactive.

temporary

logical set FALSE to save data to a persistent rappdirs location

...

parameters passed on to sf::st_read

Value

An sf data frame with LINESTRING geometries

Examples

## Not run: 
coords <- data.frame(lat = 20.79722, lon = -156.47833)
# nhd_plus_get(
#  nhdR::find_vpu(
#    sf::st_as_sf(coords, coords = c("lon", "lat"), crs = 4326)),
# temporary = FALSE)
leaf_reaches(coords$lon, coords$lat)

coords  <- data.frame(lat = 41.42217, lon = -73.24189)
l_reach <- leaf_reaches(coords$lon, coords$lat)

network_focal <- nhd_plus_query(lon = coords$lon, lat = coords$lat,
  dsn = "NHDFlowline", buffer_dist = units::as_units(2, "km"))$sp$NHDFlowline
network <- nhd_plus_query(lon = coords$lon, lat = coords$lat,
  dsn = "NHDFlowline", buffer_dist = units::as_units(5, "km"))$sp$NHDFlowline
l_reach <- leaf_reaches(network = network_focal)

plot(network$geometry)
plot(network_focal$geometry, col = "darkgreen", add=TRUE)
plot(l_reach$geometry, col = "red", add = TRUE)

## End(Not run)

nhdR documentation built on Oct. 9, 2022, 9:05 a.m.