Uses catchment splitting web service to retrieve the portion of a catchment upstream of the point provided.

get_split_catchment(point, upstream = TRUE)

Arguments

point

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

upstream

logical If TRUE, the entire drainage basin upstream of the point provided is returned in addition to the local catchment.

Value

sf data.frame containing the local catchment, the split portion and optionally the total dranage basin.

Examples

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

trace <- get_raindrop_trace(point)

(snap_point <- sf::st_sfc(sf::st_point(trace$intersection_point[[1]]),
                          crs = 4326))
#> Geometry set for 1 feature 
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -89.21343 ymin: 42.95671 xmax: -89.21343 ymax: 42.95671
#> Geodetic CRS:  WGS 84
#> POINT (-89.21343 42.95671)

(catchment <- get_split_catchment(snap_point))
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.60479 ymin: 42.9205 xmax: -89.17455 ymax: 43.36611
#> Geodetic CRS:  WGS 84
#> # A tibble: 2 × 3
#>   id              catchmentID                                           geometry
#>   <chr>           <chr>                                            <POLYGON [°]>
#> 1 catchment       13297178    ((-89.22801 42.94979, -89.22669 42.95053, -89.224…
#> 2 mergedCatchment NA          ((-89.60268 43.20938, -89.6039 43.21025, -89.6041…

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

nhdplusTools::plot_nhdplus(bbox = bbox, cache_data = FALSE)
#> Spherical geometry (s2) switched off
#> Found invalid geometry, attempting to fix.
#> 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
#> 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
#> Zoom: 11
#> 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_geometry(catchment)[2], 3857), add = TRUE, col = "black")
plot(sf::st_transform(sf::st_geometry(catchment)[1], 3857), add = TRUE, col = "red")
plot(sf::st_transform(sf::st_sfc(point, crs = 4326), 3857), add = TRUE, col = "white")


(catchment <- get_split_catchment(snap_point, upstream = FALSE))
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.22801 ymin: 42.94856 xmax: -89.19011 ymax: 42.9972
#> Geodetic CRS:  WGS 84
#> # A tibble: 2 × 3
#>   id             catchmentID                                            geometry
#>   <chr>          <chr>                                             <POLYGON [°]>
#> 1 catchment      13297178    ((-89.22801 42.94979, -89.22669 42.95053, -89.2248…
#> 2 splitCatchment NA          ((-89.19219 42.9972, -89.19145 42.99716, -89.19156…

bbox <- sf::st_bbox(catchment) + 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
#> 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
#> Zoom: 13
#> 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_geometry(catchment)[1], 3857), add = TRUE, col = "red")
plot(sf::st_transform(sf::st_geometry(catchment)[2], 3857), add = TRUE, col = "black")
plot(sf::st_transform(sf::st_sfc(point, crs = 4326), 3857), add = TRUE, col = "white")


pour_point <- sf::st_sfc(sf::st_point(x = c(-89.25619, 42.98646)), crs = 4326)

(catchment <- get_split_catchment(pour_point, upstream = FALSE))
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.27379 ymin: 42.97976 xmax: -89.2321 ymax: 43.00384
#> Geodetic CRS:  WGS 84
#> # A tibble: 2 × 3
#>   id             catchmentID                                            geometry
#>   <chr>          <chr>                                             <POLYGON [°]>
#> 1 catchment      13296592    ((-89.26258 42.98281, -89.26505 42.98306, -89.2664…
#> 2 splitCatchment NA          ((-89.25813 42.99039, -89.25824 42.98931, -89.2578…

bbox <- sf::st_bbox(catchment) + 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
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Spherical geometry (s2) switched on
#> Spherical geometry (s2) switched off
#> Warning: No nonnetwork features found
#> Spherical geometry (s2) switched on
#> Zoom: 14
#> 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_geometry(catchment)[1], 3857), add = TRUE, col = "red")
plot(sf::st_transform(sf::st_geometry(catchment)[2], 3857), add = TRUE, col = "black")
plot(sf::st_transform(sf::st_sfc(pour_point, crs = 4326), 3857), add = TRUE, col = "white")

# }