https://github.com/brownag/huckster
Very Simple Tools for Hawking Hydrologic Unit Boundaries
https://github.com/brownag/huckster
Last synced: about 2 months ago
JSON representation
Very Simple Tools for Hawking Hydrologic Unit Boundaries
- Host: GitHub
- URL: https://github.com/brownag/huckster
- Owner: brownag
- License: cc0-1.0
- Created: 2023-04-20T21:51:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-04T22:21:54.000Z (almost 2 years ago)
- Last Synced: 2025-02-08T08:47:09.852Z (4 months ago)
- Language: R
- Size: 196 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "85%",
dev = 'png'
)
```# {huckster}
[](https://github.com/brownag/huckster/actions/workflows/R-CMD-check.yaml)
The goal of {huckster} is to provide tools for easily obtaining boundaries of hydrologic units and other information based on Hydrologic Unit Codes ('HUC').
Hydrologic unit data are retrieved from the U.S. Geological Survey 'NationalMap' REST API by default. This endpoint can be customized: \.
## Installation
You can install the development version of {huckster} from [GitHub](https://github.com/brownag/huckster) with:
``` r
# install.packages("remotes")
remotes::install_github("brownag/huckster")
```## Examples
Here are some basic examples showing how to obtain hydrologic unit boundaries by ID (code), point, envelope, and polygon.
The default `layerid=5` corresponds to a "10-digit" HUC or "watershed" level boundary. See `huc_code()` for a system for encoding `layerid` from labels, code lengths or codes.
```{r examples}
library(huckster)
library(terra)## HUC code input
ids <- c("071000050101", "071000050102",
"071000050103", "071000050104")
w <- id_to_huc(ids, layer = "subwatershed")plot(w)
## point input
x <- point_to_huc(-94.0671, 43.026, layer = "subbasin")plot(x)
## SpatExtent bounding box/envelope input
y <- envelope_to_huc(terra::ext(x))## equivalently using numeric bounds:
# y <- envelope_to_huc(-94.150, 42.298, -93.636, 43.156)plot(y)
## SpatVector polygon ('Ditch Number 71' rect extent) as input
p <- terra::as.polygons(y[1, ], ext = TRUE)
z <- polygon_to_huc(p, layer = "subwatershed")plot(z)
plot(p, col = rgb(1, 0, 0, 0.5), add = TRUE)
```