extract_network: Return nhd plus stream network upstream of a waterbody

Description Usage Arguments Details Value Examples

View source: R/network.R

Description

Return nhd plus stream network upstream of a waterbody

Usage

1
2
3
4
5
6
7
8
9
extract_network(
  lon = NA,
  lat = NA,
  lines = NA,
  buffer_dist = 0.01,
  maxsteps = 3,
  approve_all_dl = FALSE,
  ...
)

Arguments

lon

numeric decimal degree longitude

lat

numeric decimal degree latitude

lines

sf spatial lines object to limit the extent of the network search

buffer_dist

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

maxsteps

maximum number of stream climbing iterations

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

The lon and lat arguments are used for querying the corresponding lake polygon layer which is then used to climb its intersecting stream network.

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
## Not run: 
library(mapview)
library(sf)

# headwater lakes have no upstream network
coords <- data.frame(lat = 46.32711, lon = -89.58893)
res <- extract_network(coords$lon, coords$lat, maxsteps = 9)

# fails if no lake nhdp lake found within the buffer at the query point
coords <- data.frame(lat = 43.62453, lon = -85.47164)
res <- extract_network(coords$lon, coords$lat, maxsteps = 9)

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

# use a projected buffer size
res <- extract_network(coords$lon, coords$lat, maxsteps = 9)

# no upstream network for lakes intersecting the Great Lakes
coords <- data.frame(lat = 44.6265, lon = -86.23121)
res <- extract_network(coords$lon, coords$lat, maxsteps = 3)

coords <- data.frame(lat = 42.96523, lon = -89.2527)
res <- extract_network(coords$lon, coords$lat, maxsteps = 9)

mapview(res)

## End(Not run)

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