Uses a raindrop trace web service to trace the nhdplus digital elevation model to the nearest downslop flowline.

get_raindrop_trace(point, direction = "down")

Arguments

point

sfc POINT including crs as created by: sf::st_sfc(sf::st_point(.. ,..), crs)

direction

character "up", "down", or "none". Controls the portion of the split flowline that is returned along with the raindrop trace line.

Value

sf data.frame containing raindrop trace and requested portion of flowline.

Examples

# \donttest{
point <- sf::st_sfc(sf::st_point(x = c(-89.2158, 42.9561)), crs = 4326)

(trace <- get_raindrop_trace(point))
#> Simple feature collection with 2 features and 7 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -89.21572 ymin: 42.94986 xmax: -89.20944 ymax: 42.95699
#> Geodetic CRS:  WGS 84
#> # A tibble: 2 × 8
#>   id       gnis_name   comid reachcode raindrop_pathDi… measure intersection_po…
#>   <chr>    <chr>       <int> <chr>                <dbl>   <dbl> <list>          
#> 1 downstr… Yahara R…  1.33e7 07090002…             273.    29.7 <dbl [2]>       
#> 2 raindro… NA        NA      NA                     NA     NA   <dbl [0]>       
#> # … with 1 more variable: geometry <LINESTRING [°]>

bbox <- sf::st_bbox(trace) + c(-0.005, -0.005, 0.005, 0.005)

nhdplusTools::plot_nhdplus(bbox = bbox, cache_data = FALSE)
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Spherical geometry (s2) switched off
#> Warning: No waterbodies features found
#> Spherical geometry (s2) switched on
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Zoom: 15
#> Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
#> Audotdetect projection: assuming Google Mercator (epsg 3857)

plot(sf::st_transform(sf::st_sfc(point, crs = 4326), 3857), add = TRUE)
plot(sf::st_transform(sf::st_geometry(trace)[1], 3857), add = TRUE, col = "red")
plot(sf::st_transform(sf::st_geometry(trace)[2], 3857), add = TRUE, col = "black")

# }