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

point_to_huc(
  x,
  y = NULL,
  layer = "watershed",
  layerid = huc_code(layer),
  sr_in = 4326,
  sr_out = sr_in,
  base_url = huckster_usgs_hydro_wbd_url()
)

Arguments

x

A SpatVector object or numeric vector.

y

NULL (when x is a spatial object); otherwise a numeric vector equal in length to x

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.

sr_in

integer. Spatial Reference System of input (x, y) as specified with numeric code. Default: 4326 for "EPSG:4326".

sr_out

integer. Spatial Reference System of result as specified with numeric code. Default: sr_in; equivalent to input.

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) {
point_to_huc(-120, 36:39)
}