terminal_reaches: Return terminal reaches from collection intersecting lake

Description Usage Arguments Details Value Examples

View source: R/network.R

Description

In the case of a network query, a terminal reach is a stream flowline that has no downstream reaches in-network. In the case of a point query, a terminal reach is a flowline that exits the intersecting surface waterbody.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
terminal_reaches(
  lon = NA,
  lat = NA,
  buffer_dist = 0.01,
  network = NA,
  lakepoly = NA,
  lakewise = FALSE,
  lakesize_threshold = 4,
  approve_all_dl = FALSE,
  ...
)

Arguments

lon

numeric decimal degree longitude. optional. See Details section.

lat

numeric decimal degree latitude. optional. See Details section.

buffer_dist

numeric buffer around lat-lon point in dec. deg.

network

sf lines collection. optional. See Details section.

lakepoly

sf polygon. optional. See Details section.

lakewise

logical. If TRUE, return the terminal reaches of all lakes. in the stream network rather than a single terminal reach of the focal lake.

lakesize_threshold

numeric above which to count as a lake (ha).

approve_all_dl

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

...

parameters passed on to sf::st_read

Details

There are multiple ways to execute terminal_reaches:

Value

An sf data frame with LINESTRING geometries

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
library(sf)
library(mapview)

coords <- data.frame(lat = 46.32711, lon = -89.58893)
t_reach <- terminal_reaches(coords$lon, coords$lat)

coords <- data.frame(lat = 20.79722, lon = -156.47833)
# use a non-geographic (projected) buffer size
t_reach <- terminal_reaches(coords$lon, coords$lat,
  buffer_dist = units::as_units(5, "km"))

coords  <- data.frame(lat = 42.96628, lon = -89.25264)
t_reach <- terminal_reaches(coords$lon, coords$lat)

coords  <- data.frame(lat = 41.42217, lon = -73.24189)
t_reach <- terminal_reaches(coords$lon, coords$lat)

mapview(st_as_sf(coords, coords = c("lon", "lat"), crs = 4326)) +
  mapview(t_reach$geometry, color = "red")

coords <- data.frame(lat = 41.859080, lon = -71.575422)
network <- nhd_plus_query(lon = coords$lon, lat = coords$lat,
  dsn = "NHDFlowline", buffer_dist = 0.05)$sp$NHDFlowline
t_reach      <- terminal_reaches(network = network)
t_reach_lake <- terminal_reaches(network = network, lakewise = TRUE,
  lakesize_threshold = 1)

mapview(network) + mapview(t_reach_lake, color = "green") +
  mapview(t_reach, color = "red")

## End(Not run)

nhdR documentation built on July 17, 2021, 5:06 p.m.