Skip to content

Experimental data retrieval package for developing SELECT

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

TxWRI/SELECTRdata

Repository files navigation

SELECTRdata

Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. R-CMD-check Codecov test coverage SELECTRdata status badge

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:

Installation

You can install the development version of SELECTRdata like so:

install.packages("SELECTRdata", repos = c("https://txwri.r-universe.dev", "https://cloud.r-project.org"))

Examples

USGS DEM

library(SELECTRdata)
library(terra)
#> Warning: package 'terra' was built under R version 4.3.3
#> terra 1.8.29

## 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

## 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"))
## 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

buildings <- download_buildings(template = dem)
#> Registered S3 method overwritten by 'jsonify':
#>   method     from    
#>   print.json jsonlite
#> Iterating ■■■■■ 12% | ETA: 8sIterating ■■■■■■■■■ 25% | ETA: 6sIterating
#> ■■■■■■■■■■■■ 38% | ETA: 4sIterating ■■■■■■■■■■■■■■■■■■■■ 62% | ETA: 2sIterating
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 88% | ETA: 0s
plot(buildings)
plot(wbd, add = TRUE)

U.S. Census Blocks

Includes housing unit and population data.

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.

counties <- download_counties(dem)
plot(counties)
plot(wbd, add = TRUE)

Urbanized Areas

U.S. Census designated urban areas from the 2020 U.S. Census.

ua <- download_urban_areas(dem)
plot(wbd)
plot(ua, col = "red", alpha = 0.5, add = TRUE)

NPDES Permits

npdes <- download_NPDES_permits(dem)
#> ℹ Query returned 3 results!
plot(wbd)
plot(npdes, add = TRUE)

About

Experimental data retrieval package for developing SELECT

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages