-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
153 lines (110 loc) · 4.29 KB
/
Copy pathREADME.Rmd
File metadata and controls
153 lines (110 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
output: github_document
---
<!-- You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. -->
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# SELECTRdata
<!-- badges: start -->
[](https://www.repostatus.org/#wip)
[](https://github.com/TxWRI/SELECTRdata/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/TxWRI/SELECTRdata?branch=main)
[](https://txwri.r-universe.dev/SELECTRdata)
<!-- badges: end -->
SELECTRdata provides convenience functions for downloading raster and tabular
data used in the Spatially Explicit Load Enrichment Calculation Tool (SELECT).
By providing a SpatRaster object of the target watershed, functions are available
to download cropped:
- [National Land Cover Dataset](https://www.mrlc.gov/)
- [FEMA USA Structures](https://disasters.geoplatform.gov/USA_Structures/)
- [Census Blocks](https://tigerweb.geo.census.gov/tigerwebmain/TIGERweb_restmapservice.html)
- [TIGER County Boundaries](https://tigerweb.geo.census.gov/tigerwebmain/TIGERweb_restmapservice.html)
- [USDA Agricultural Census](https://www.nass.usda.gov/)
- [EPA NPDES Permits](https://echo.epa.gov/)
- [U.S. Census Bureau Urbanized Areas](https://www.census.gov/programs-surveys/geography/guidance/geo-areas/urban-rural.html)
## Installation
You can install the development version of SELECTRdata like so:
``` r
install.packages("SELECTRdata", repos = c("https://txwri.r-universe.dev", "https://cloud.r-project.org"))
```
## Examples
### USGS DEM
```{r dem}
library(SELECTRdata)
library(terra)
## our location of interest
location_of_interest <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
location_of_interest <- terra::rast(location_of_interest)
## grab the extent
extent <- ext(location_of_interest)
## create a extent or object that an extent and srs
## can be grabbed
extent <- vect(extent, crs = crs(location_of_interest))
## project the extent to something used by USGS Seamless data
extent <- project(extent, "EPSG:6579")
## grab the epsg code from our extent
auth <- crs(extent, describe = TRUE)
auth <- paste0(auth$authority, ":", auth$code)
extent <- ext(extent)
## download DEM
example_dem <- download_dem(x = extent, srs = auth)
plot(example_dem)
```
### MRLC National Land Cover Dataset
```{r example}
## we need a template file, this is the thomsoncreek watershed in Texas
dem <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
dem <- terra::rast(dem)
gpkg <- system.file("extdata", "thompsoncreek.gpkg", package = "SELECTRdata")
wbd <- terra::vect(gpkg, layer = "wbd")
dem <- terra::mask(dem, wbd,
filename = tempfile(fileext = ".tif"))
```
```{r}
## download the NLCD file cropped to the extents of the watershed
nlcd <- SELECTRdata::download_nlcd(template = dem,
overwrite = TRUE,
progress = 1)
plot(nlcd)
plot(wbd, add = TRUE)
```
### FEMA US Buildings
```{r}
buildings <- download_buildings(template = dem)
plot(buildings)
plot(wbd, add = TRUE)
```
### U.S. Census Blocks
Includes housing unit and population data.
```{r}
cen_blocks <- download_census_blocks(dem, "2020")
plot(cen_blocks, "P0010001")
plot(wbd, col = "white", alpha = 0.5, add = TRUE)
```
### TIGER Counties
County boundaries cropped to coastlines.
```{r}
counties <- download_counties(dem)
plot(counties)
plot(wbd, add = TRUE)
```
## Urbanized Areas
U.S. Census designated urban areas from the 2020 U.S. Census.
```{r}
ua <- download_urban_areas(dem)
plot(wbd)
plot(ua, col = "red", alpha = 0.5, add = TRUE)
```
## NPDES Permits
```{r}
npdes <- download_NPDES_permits(dem)
plot(wbd)
plot(npdes, add = TRUE)
```