polygon_to_huc.RdHydrologic unit boundaries are retrieved from the USGS NationalMap ArcGIS MapServer web services: "https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/".
polygon_to_huc(
x,
layer = "watershed",
layerid = huc_code(layer),
sr_in = 4326,
sr_out = sr_in,
base_url = huckster_usgs_hydro_wbd_url()
)character. WKT string.
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) {
x <- 'POLYGON((-121.355 37.56,-121.355 37.555,
-121.35 37.555,-121.35 37.56,
-121.355 37.56))' |>
terra::vect(crs = "OGC:CRS84")
polygon_to_huc(x, layer = "subwatershed")
}