Multipurpose function to find a COMID of interest.

Note that NHDPlusV2 uses "featureid" for catchment polygons and "comid" for flowline linestrings. These two identifiers are the same where a flowline/catchment pair exists. In some cases, a catchment will not have a flowline and in others, a flowline will not have a catchment.

If a point is provided, and raindrop is false, the comid/featureid integer of the catchment the point is in is returned. This options uses a web service here: https://api.water.usgs.gov/fabric/pygeoapi/collections/catchmentsp

If a point is provided, and raindrop is true, the response is the result of a call to get_raindrop_trace.

If no point is provided, the raindrop argument is ignored and the result is a comid integer derived from a call to get_nldi_feature.

discover_nhdplus_id(point = NULL, nldi_feature = NULL, raindrop = FALSE)

Arguments

point

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

nldi_feature

list with names `featureSource` and `featureID` where `featureSource` is derived from the "source" column of the response of get_nldi_sources and the `featureSource` is a known identifier from the specified `featureSource`.

raindrop

logical if TRUE will call a raindrop trace web service and return will be the same as get_raindrop_trace with direction "none".

Value

integer COMID or list containing COMID and raindrop trace.

Examples

# \donttest{
point <- sf::st_sfc(sf::st_point(c(-76.874, 39.482)), crs = 4326)
discover_nhdplus_id(point)
#> [1] 11689978

discover_nhdplus_id(point, raindrop = TRUE)
#> Simple feature collection with 2 features and 7 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -76.88292 ymin: 39.47138 xmax: -76.86733 ymax: 39.49148
#> Geodetic CRS:  WGS 84
#> # A tibble: 2 × 8
#>   id    gnis_name   comid reachcode raindrop_pathDist measure intersection_point
#>   <chr> <chr>       <int> <chr>                 <dbl>   <dbl> <list>            
#> 1 nhdF… North Br…  1.17e7 02060003…                61    54.0 <dbl [2]>         
#> 2 rain… NA        NA      NA                       NA    NA   <dbl [0]>         
#> # ℹ 1 more variable: geometry <LINESTRING [°]>

nldi_nwis <- list(featureSource = "nwissite", featureID = "USGS-08279500")
discover_nhdplus_id(nldi_feature = nldi_nwis)
#> [1] 17864756
# }