Joins geoconnex mainstem identifiers onto a table that contains NHDPlusV2 (comid/featureid) or NHDPlusHR (nhdplusid) identifiers using a lookup table.

add_mainstems(x, join_col = NULL, join_col_type = NULL)

Arguments

x

data.frame or sf containing an identifier column joinable to NHDPlusV2 or NHDPlusHR.

join_col

character name of the identifier column in x. Detected automatically from comid, featureid, or nhdplusid (any case) if not provided.

join_col_type

character one of "nhdpv2" or "nhdphr". Detected automatically from join_col if not provided.

Value

x with mainstem_uri and mainstemid columns added.

Details

Source data comes from the ref_rivers GitHub release here. The csv source data is downloaded once, converted to parquet, and cached in the user data dir indicated by hydrogeofetch_data_dir.

Examples

# \donttest{
add_mainstems(data.frame(comid = c(2804607, 2804621)))
#>     comid                               mainstem_uri mainstemid
#> 1 2804607 https://geoconnex.us/ref/mainstems/1826652    1826652
#> 2 2804621 https://geoconnex.us/ref/mainstems/1826652    1826652
# }