envelope_to_huc.RdHydrologic unit boundaries are retrieved from the USGS NationalMap ArcGIS MapServer web services: "https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/".
envelope_to_huc(
x,
...,
layer = "watershed",
layerid = huc_code(layer),
sr_in = 4326,
sr_out = sr_in,
base_url = huckster_usgs_hydro_wbd_url()
)A SpatExtent object (or object coercible to one) or numeric vector.
Additional arguments are (in order) ymin, xmax, ymax when x is numeric (xmin).
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.
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.
integer. Spatial Reference System of input (x, y) as specified with numeric code. Default: 4326 for "EPSG:4326".
integer. Spatial Reference System of result as specified with numeric code. Default: sr_in; equivalent to input.
Default: "https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/"
A SpatVector object derived from GeoJSON.
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)
if (FALSE) {
envelope_to_huc(-121, 36, -120, 37, layer = "subbasin")
}