Hydrologic unit boundaries are retrieved from the USGS NationalMap ArcGIS MapServer web services: "https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/".

id_to_huc(
  x,
  layer = x,
  layerid = huc_code(layer),
  base_url = huckster_usgs_hydro_wbd_url()
)

Arguments

x

character. Hydrologic Unit IDs

layer

One or more: labels, codes, or code lengths to convert to layerid. Default "watershed", which is equivalent to "10-digit", "10" or any 10-digit code.

layerid

numeric. 1:8 where 2*layerid is equal to the number of digits in the Hydrologic Unit Code (HUC). Default: 5 derived from "watershed" for "10-digit" hydrologic unit boundary. See details.

base_url

Default: "https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/"

Value

A SpatVector object derived from GeoJSON.

Details

The levels of layerid correspond to the numeric codes for the following hydrologic units (HU):

  • WBDLine (0)

  • 2-digit HU (Region) (1)

  • 4-digit HU (Subregion) (2)

  • 6-digit HU (Basin) (3)

  • 8-digit HU (Subbasin) (4)

  • 10-digit HU (Watershed) (5)

  • 12-digit HU (Subwatershed) (6)

  • 14-digit HU (7)

  • 16-digit HU (8)

Examples

if (FALSE) {
x <- id_to_huc(c("071000050101", "071000050102", "071000050103", "071000050104"))
terra::plot(x)
}