Package 'SELECTRdata'

Title: Download and Format Spatially Explicit Load Enrichment Calculation Tool ('SELECT') Data
Description: Provides convienence functions for downloading raster and tabular data used by Spatially Explicit Load Enrichment Calculation Tool ('SELECT') to characterize landscape based pollutant sources (<https://tx.select.tamu.edu>). Methodology based on Teague et al. (2009) <doi:10.13031/2013.27788>.
Authors: Michael Schramm [aut, cre]
Maintainer: Michael Schramm <mpschramm@gmail.com>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2025-03-05 16:38:04 UTC
Source: https://github.com/TxWRI/SELECTRdata

Help Index


Download building footprints

Description

Downloads building footprints and attribute data from FEMA's USA Structures dataset (https://fema.maps.arcgis.com/home/item.html?id=0ec8512ad21e4bb987d7e848d14e7e24#overview).

Usage

download_buildings(
  template,
  return = "SpatVector",
  output = tempfile(fileext = ".gpkg")
)

Arguments

template

A SpatRaster object. The extent of the returned object will match template.

return

A character object, either SpatVector or sf. Defaults to SpatVector.

output

A character file path specifying where the SpatVector file should be written. Defaults to a temporary file.

Value

A SpatVector or sf object with extents matching the SpatRaster object provided in the template argument. If API resources are not available an invisible NULL is returned.

Examples

## This example requires an internet connection to run
dem <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
dem <- terra::rast(dem)

buildings <- download_buildings(template = dem)

Download U.S. Census block boundaries

Description

Downloads U.S. Census block boundaries and associated information for blocks within the spatial extent of the template SpatRaster.

Usage

download_census_blocks(
  template,
  year = "2020",
  page_size = NULL,
  output = tempfile(fileext = ".gpkg")
)

Arguments

template

A SpatRaster object.

year

A character value. Any of the following values should work: c("2000","2010","2020").

page_size

a numeric value passed to arcgislayers::arcselect(). Defaults to NULL. Useful when the requests returns a 500 error code.

output

A character file path specifying where the raster file should be stored. Defaults to a temporary file.

Value

A terra SpatVector object. If API resources are not available an invisible NULL is returned.

Examples

# example code

## This example requires an internet connection to run
dem <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
dem <- terra::rast(dem)

blocks <- download_census_blocks(template = dem)
blocks

Download TIGER county spatial data.

Description

Shortcut function that downloads and extracts TIGER U.S. County boundaries and returns them as a terra SpatVector object.

Usage

download_counties(template, output = tempfile(fileext = ".gpkg"))

Arguments

template

A SpatRaster object.

output

A character file path specifying where the raster file should be stored. Defaults to a temporary file.

Value

A terra SpatVector object. If API resources are not available an invisible NULL is returned.

Examples

# example code

## This example requires an internet connection to run
dem <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
dem <- terra::rast(dem)

counties <- download_counties(template = dem)

Download county level total livestock

Description

Provides a wrapper to rnassqs::nassqs() with simplified arguments for making queries that return county level livestock estimates. This function requires an API key from USDA NASS Quickstats. See details for more information.

Usage

download_nass_livestock(
  state_alpha = NULL,
  county_name = NULL,
  year = "2022",
  ...
)

Arguments

state_alpha

Two letter character abbreviation for state.

county_name

Character, county name.

year

A character to filter the NASS Agriculture Census year. Expects one of: c('2022', '2017', '2012', '2007', '2002', '1997').

...

Additional arguments passed to rnassqs::nassqs()

Details

This function requires an API key to make requests on the USDA NASS QuickStats service.

  1. Obtain an API key from https://quickstats.nass.usda.gov/api/.

  2. Set the NASSQS_TOKEN variable in your global environment. This can be done with ⁠Sys.setenv('NASSQS_TOKEN' = <your api key>)⁠, or usethis::edit_r_environment().

  3. Restart your session.

Value

A dataframe.

Examples

download_nass_livestock(state_alpha = "TX", county_name = "Brazos", year = "2022")

Download and write annual NLCD raster data to file.

Description

Downloads and writes an NLCD SpatRaster to file with extents defined by template. This function downloads the annualized NLCD data products. See https://www.mrlc.gov/data/project/annual-nlcd for more information.

Usage

download_nlcd(
  template,
  year = "2021",
  dataset = "LndCov",
  landmass = "CU",
  output = tempfile(fileext = ".tiff"),
  overwrite = FALSE,
  verbose = FALSE,
  ...
)

Arguments

template

A SpatRaster object defining the spatial extent of the returned NLCD raster.

year

character, expects a value between 1986:2023.

dataset

Character. Expects c("LndCov","LndChg","LndCnf","FctImp","ImpDsc","SpcChg").

landmass

Character, one of: c("CU", "AK", "HI").

output

A character file path specifying where the raster file should be stored. Defaults to a temporary file.

overwrite

logical. If TRUE, filename is overwritten

verbose

Logical, if TRUE informative messages will be printed.

...

additional arguments for for writing files, see terra::writeRaster()

Value

A SpatRaster object with file written to output


Download NPDES permits

Description

Downloads NPDES permits from EPA ECHO API services within the bounds of the SpatRast template.

Usage

download_NPDES_permits(
  template,
  permit_component = "POT",
  permit_status = "EFF",
  output = tempfile(fileext = ".gpkg")
)

Arguments

template

A SpatRaster object.

permit_component

A character vector with one or more of the following: PRE (pretreatment), CAF (CAFO), CSO (CSO), POT (Publicly Owned Treatment Works, the default), BIO (Biosolids), SWS (Stormwater Small MS4), SWM (Stormwater Medium/Large MS4), SWI (Stormwater Industrial), SWC (Stormwater Construction).

permit_status

A character vector with one or more of the following: EFF (effective, the default), EXP (expired), PND (pending), TRM (terminated), RET (retired), NON (not needed), ADC (administratively continued).

output

A character file path specifying where the raster file should be stored. Defaults to a temporary file.

Value

SpatVector object

Examples

dem <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
dem <- terra::rast(dem)
download_NPDES_permits(dem)

Download U.S. Urban Areas

Description

Downloads a U.S. Census designated urban areas intersecting the spatial extent of the template SpatRaster.

Usage

download_urban_areas(
  template,
  page_size = NULL,
  output = tempfile(fileext = ".gpkg")
)

Arguments

template

A SpatRaster object.

page_size

a numeric value passed to arcgislayers::arcselect(). Defaults to NULL. Useful when the requests returns a 500 error code.

output

A character file path specifying where the SpatVector output object should be written. Defaults to a temporary file.

Value

A terra SpatVector object. If API resources are not available an invisible NULL is returned.

Examples

# example code

## This example requires an internet connection to run
dem <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
dem <- terra::rast(dem)

ua <- download_urban_areas(template = dem)
ua

Is there a NASS token?

Description

Checks if a NASS token has been set in the user environment.

Usage

has_nass_token()

Value

logical

Examples

has_nass_token()

Set GDAL configuration options

Description

A convenience functions for simultaneously setting the GDAL runtime configuration options in both terra and gdalraster.

Usage

set_gdal_config(option, value)

Arguments

option

Character name of a configuration option.

value

Character value to set for the option. value = "" (empty string) will unset previously set values.

Value

No return value, called for side effects.

See Also

terra::setGDALconfig() and gdalraster::set_config_option()

Examples

set_gdal_config("GDAL_CACHEMAX", "10%")
## unset
set_gdal_config("GDAL_CACHEMAX", "")

Thompsons Creek Elevation Data

Description

Elevation raster of the Thompsons Creek watershed outside of College Station, Texas. This data is obtained from the hydroreinforced digital elevation model (DEM) rasters that are part of the United States Geological Survey (USGS) and United States Environmental Protection Agency (EPA) National Hydrography Dataset Plus (NHDPlus).

See Also

https://nhdplus.com/NHDPlus/NHDPlusV2_home.php

Examples

thompson <- system.file("extdata", "thompsoncreek.tif", package = "SELECTRdata")
terra::rast(thompson)

Thompsons Creek Watershed Boundary

Description

Polygon boundary of the Thompsons Creek watershed (Collecge Station, Texas). This watershed boundary was created using the hydroreinformced raster from the United States Geological Survey (USGS) and United States Environmental Protection Agency (EPA) National Hydrography Dataset Plus (NHDPlus) dataset.

See Also

thompson()

Examples

gpkg <- system.file("extdata", "thompsoncreek.gpkg", package = "SELECTRdata")
terra::vect(gpkg, layer = "wbd")