nhd_query: Select NHD features clipped by a circular buffer a coordinate...

View source: R/query.R

nhd_queryR Documentation

Select NHD features clipped by a circular buffer a coordinate pair

Description

Select NHD features clipped by a circular buffer a coordinate pair

Usage

nhd_query(
  lon = NA,
  lat = NA,
  poly = NA,
  dsn,
  approve_all_dl = FALSE,
  buffer_dist = units::as_units(4.75, "km"),
  temporary = TRUE,
  ...
)

Arguments

lon

numeric longitude

lat

numeric latitude

poly

sfc polygon. optional

dsn

character data source

approve_all_dl

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

buffer_dist

numeric buffer with specified units

temporary

logical set FALSE to save data to a persistent rappdirs location

...

other arguments passed to sf::st_read

Examples

## Not run: 
library(sf)
wk <- wikilake::lake_wiki("Worden Pond")
qry <- nhd_query(wk$Lon, wk$Lat, dsn = c("NHDWaterbody", "NHDFlowLine"),
  buffer_dist = units::as_units(1, "km"))
qry$sp$NHDWaterbody <- dplyr::filter(qry$sp$NHDWaterbody, FType != 466)

plot(sf::st_geometry(qry$sp$NHDWaterbody), col = "blue")
plot(sf::st_geometry(qry$sp$NHDFlowLine), col = "cyan", add = TRUE)
plot(qry$pnt, col = "red", pch = 19, add = TRUE)
axis(1)
axis(2)

# query with a polygon
wbd <- qry$sp$NHDWaterbody[
  order(st_area(qry$sp$NHDWaterbody), decreasing = TRUE), ][1, ]
qry_lines <- nhd_query(poly = st_as_sfc(st_bbox(wbd)), dsn = "NHDFlowLine")
library(ggplot2)
ggplot() +
  geom_sf(data = qry$sp$NHDWaterbody) +
  geom_sf(data = qry_lines$sp$NHDFlowLine, color = "red")

## End(Not run)

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