| Title: | 'StreamCatTools' |
|---|---|
| Description: | Tools for using the 'StreamCat' and 'LakeCat' API and interacting with the 'StreamCat' and 'LakeCat' database. Convenience functions in the package wrap the API for 'StreamCat' on <https://api.epa.gov/StreamCat/streams/metrics>. |
| Authors: | Marc Weber [aut, cre], Ryan Hill [ctb], Selia Markley [ctb], Travis Hudson [ctb], Allen Brookes [ctb], David Rebhuhn [ctb], Michael Dumelle [ctb], Justin Bousquin [ctb], Zachary Smith [ctb] |
| Maintainer: | Marc Weber <[email protected]> |
| License: | CC0 |
| Version: | 0.11.0 |
| Built: | 2026-05-24 06:29:46 UTC |
| Source: | https://github.com/usepa/streamcattools |
Function to retrieve a full metric name based on the short name using the LakeCat API.
lc_fullname(metric = NULL)lc_fullname(metric = NULL)
metric |
Short metric name Syntax: metric=value1 Values: metric |
A lookup of the full name for a given LakeCat metric
Marc Weber
fullname <- lc_fullname(metric='clay')fullname <- lc_fullname(metric='clay')
Function to return NHDPlusV2 Waterbody COMIDS using either a dataframe with coordinates and a specified CRS or an sf object. The function generates a vector of NHDPlus Waterbody COMID values a user can then pass to lc_get_data function
lc_get_comid( dd = NULL, xcoord = NULL, ycoord = NULL, crsys = NULL, buffer = NULL )lc_get_comid( dd = NULL, xcoord = NULL, ycoord = NULL, crsys = NULL, buffer = NULL )
dd |
Name of data frame object. Can be a simple data frame with coordinate columns in a known CRS or an sf points data frame |
xcoord |
The x coordinate column if using a raw data frame |
ycoord |
The y coordinate column if using a raw data frame |
crsys |
The epsg code if using a raw data frame |
buffer |
The amount of buffer to use to extend search for a waterbody (simply passed to nhdplusTools::get_waterbodies) |
A new sf data frame with a populated 'COMID' column
Marc Weber
## Not run: dd <- data.frame(x = c(-89.198,-114.125,-122.044), y = c(45.502,47.877,43.730)) comids <- lc_get_comid(dd, xcoord='x', ycoord='y', crsys=4269) dd <- data.frame(x = c(-89.198,-114.125,-122.044), y = c(45.502,47.877,43.730)) |> sf::st_as_sf(coords = c('x', 'y'), crs = 4326) comids <- lc_get_comid(dd) ## End(Not run)## Not run: dd <- data.frame(x = c(-89.198,-114.125,-122.044), y = c(45.502,47.877,43.730)) comids <- lc_get_comid(dd, xcoord='x', ycoord='y', crsys=4269) dd <- data.frame(x = c(-89.198,-114.125,-122.044), y = c(45.502,47.877,43.730)) |> sf::st_as_sf(coords = c('x', 'y'), crs = 4326) comids <- lc_get_comid(dd) ## End(Not run)
Function to return LakeCat metrics using the StreamCat API. The function allows a user to get specific metric data aggregated by area of interest, returned by comid(s), hydroregion(s), state(s), or county(ies).
lc_get_data( comid = NULL, metric = NULL, aoi = NULL, showAreaSqKm = NULL, showPctFull = NULL, state = NULL, county = NULL, region = NULL, conus = NULL, countOnly = NULL )lc_get_data( comid = NULL, metric = NULL, aoi = NULL, showAreaSqKm = NULL, showPctFull = NULL, state = NULL, county = NULL, region = NULL, conus = NULL, countOnly = NULL )
comid |
Return metric information for specific COMIDs. Can be a comma-delimited list, a character vector,
or any object that can be coerced to a comma-delimited list with |
metric |
Name(s) of metrics to query. Must be character string with comma-delimited list of metrics. Not case-sensitive. Syntax: name=<name1>,<name2> |
aoi |
Specify the area of interest described by a metric. By default, all available areas of interest for a given metric are returned. Case-sensitive. Syntax: areaOfInterest=<value1>,<value2> Values: catchment|watershed| |
showAreaSqKm |
Return the area in square kilometers of a given area of interest. The default value is false. Values: true|false |
showPctFull |
Return the pctfull for each dataset. The default value is false. Values: true|false |
state |
Return metric information for COMIDs within a specific state. Use a state's abbreviation to
query for a given state. One of |
county |
Return metric information for COMIDs within a specific county.
Users must use the FIPS code, not county name, as a way to disambiguate counties.
One of |
region |
Return metric information for COMIDs within a specified hydroregion.
Hydroregions are specified using full name i.e. |
conus |
Return all COMIDs in the conterminous United States. Character string (Not case-sensitive) or logical.
The default value is false. If true, |
countOnly |
Return a CSV containing only the row count (ROWCOUNT) and the column count (COLUMNCOUNT) that the server expects to return in a request. The default value is false. Values: true|false |
A tibble of desired StreamCat metrics. If data are missing for all rows of a given metric, then the column for that metric will not exist. If data are missing for only some rows, then they will be specified with NA.
Marc Weber
## Not run: df <- lc_get_data(comid='23794487', aoi='cat', metric='fert') df <- lc_get_data(metric='pcturbmd2006', aoi='ws', comid='24083377') df <- lc_get_data(metric='pctgrs2006', aoi='ws', region='Region01') df <- lc_get_data(metric='pctwdwet2006', aoi='ws', county='41003') df <- lc_get_data(metric='pcturbmd2006', aoi='ws', comid='24083377', showAreaSqKm=FALSE, showPctFull=TRUE) df <- lc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='23783629,23794487,23812618') df <- lc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid=c('23783629','23794487','23812618')) df <- lc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='23783629,23794487,23812618', countOnly=TRUE) ## End(Not run)## Not run: df <- lc_get_data(comid='23794487', aoi='cat', metric='fert') df <- lc_get_data(metric='pcturbmd2006', aoi='ws', comid='24083377') df <- lc_get_data(metric='pctgrs2006', aoi='ws', region='Region01') df <- lc_get_data(metric='pctwdwet2006', aoi='ws', county='41003') df <- lc_get_data(metric='pcturbmd2006', aoi='ws', comid='24083377', showAreaSqKm=FALSE, showPctFull=TRUE) df <- lc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='23783629,23794487,23812618') df <- lc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid=c('23783629','23794487','23812618')) df <- lc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='23783629,23794487,23812618', countOnly=TRUE) ## End(Not run)
Function to filter LakeCat metrics metrics by category, area of interest, dataset or year. Use 'lc_get_params(categories)' or 'lc_get_params(datasets)' to see all the valid category or dataset options
lc_get_metric_names(category = NULL, aoi = NULL, year = NULL, dataset = NULL)lc_get_metric_names(category = NULL, aoi = NULL, year = NULL, dataset = NULL)
category |
Filter LakeCat metrics based on the metric category |
aoi |
Filter LakeCat metrics based on the area of interest |
year |
Filter LakeCat metrics based on a particular year or years |
dataset |
Filter LakeCat metrics based on the dataset name |
A dataframe of merics and description that match filter criteria
Marc Weber
## Not run: metrics <- lc_get_metric_names(category='Natural') metrics <- lc_get_metric_names(category = c('Anthropogenic','Natural'), aoi=c('Cat','Ws')) ## End(Not run)## Not run: metrics <- lc_get_metric_names(category='Natural') metrics <- lc_get_metric_names(category = c('Anthropogenic','Natural'), aoi=c('Cat','Ws')) ## End(Not run)
'r lifecycle::badge("deprecated")' 'lc_nlcd()' was renamed to 'lc_get_nlcd()' to create a more consistent API. Function to specifically retrieve all NLCD metrics for a given year using the StreamCat API.
lc_get_nlcd( year = "2019", comid = NULL, aoi = NULL, showAreaSqKm = NULL, showPctFull = NULL, state = NULL, county = NULL, region = NULL, conus = NULL, countOnly = NULL )lc_get_nlcd( year = "2019", comid = NULL, aoi = NULL, showAreaSqKm = NULL, showPctFull = NULL, state = NULL, county = NULL, region = NULL, conus = NULL, countOnly = NULL )
year |
Years(s) of NLCD metrics to query. Only valid NLCD years are accepted (i.e. 2001, 2004, 2006, 2008, 2011, 2013, 2016, 2019) Syntax: year=<year1>,<year2> |
comid |
Return metric information for specific COMIDs Syntax: comid=<comid1>,<comid2> |
aoi |
Specify the area of interest described by a metric. By default, all available areas of interest for a given metric are returned. Syntax: areaOfInterest=<value1>,<value2> Values: catchment|watershed|riparian_catchment|riparian_watershed|other |
showAreaSqKm |
Return the area in square kilometers of a given area of interest. The default value is false. Values: true|false |
showPctFull |
Return the pctfull for each dataset. The default value is false. Values: true|false |
state |
Return metric information for COMIDs within a specific state. Use a state's abbreviation to query for a given state. Syntax: state=<state1>,<state2> |
county |
Return metric information for COMIDs within a specific county. Users must use the FIPS code, not county name, as a way to disambiguate counties. Syntax: county=<county1>,<county1> |
region |
Return metric information for COMIDs within a specified hydroregion. Syntax: region=<regionid1>,<regionid2> |
conus |
Return all COMIDs in the conterminous United States. The default value is false. Values: true|false |
countOnly |
Return a CSV containing only the row count (ROWCOUNT) and the column count (COLUMNCOUNT) that the server expects to return in a request. The default value is false. Values: true|false |
A tibble of desired StreamCat metrics
Marc Weber
## Not run: df <- lc_get_nlcd(comid='23783629', year='2019', aoi='ws') # Will show a deprecation warning df <- lc_get_nlcd(comid='23783629', year='2019', aoi='ws') df <- lc_get_nlcd(year='2016', aoi='cat', comid='23783629,23794487,23812618', showAreaSqKm=FALSE, showPctFull=TRUE) df <- lc_get_nlcd(year='2016', aoi='cat', comid='23783629,23794487,23812618', countOnly=TRUE) df <- lc_get_nlcd(year='2016, 2019', aoi='cat,ws', comid='23783629,23794487,23812618') ## End(Not run)## Not run: df <- lc_get_nlcd(comid='23783629', year='2019', aoi='ws') # Will show a deprecation warning df <- lc_get_nlcd(comid='23783629', year='2019', aoi='ws') df <- lc_get_nlcd(year='2016', aoi='cat', comid='23783629,23794487,23812618', showAreaSqKm=FALSE, showPctFull=TRUE) df <- lc_get_nlcd(year='2016', aoi='cat', comid='23783629,23794487,23812618', countOnly=TRUE) df <- lc_get_nlcd(year='2016, 2019', aoi='cat,ws', comid='23783629,23794487,23812618') ## End(Not run)
Function to get all NNI data available for a given year.
lc_get_nni( year, aoi = NULL, comid = NULL, showAreaSqKm = TRUE, showPctFull = NULL, countOnly = NULL )lc_get_nni( year, aoi = NULL, comid = NULL, showAreaSqKm = TRUE, showPctFull = NULL, countOnly = NULL )
year |
Years(s) of NNI metrics to query. Only valid NNI years are accepted (1987:2017) Syntax: year=<year1>,<year2> |
aoi |
Specify the area of interest described by a metric. By default, all available areas of interest for a given metric are returned. Syntax: areaOfInterest=<value1>,<value2> Values: catchment|watershed |
comid |
Return metric information for specific COMIDs Syntax: comid=<comid1>,<comid2> |
showAreaSqKm |
Return the area in square kilometers of a given area of interest. The default value is true. Values: true|false |
showPctFull |
Return the pctfull for each dataset. The default value is false. Values: true|false |
countOnly |
Return a CSV containing only the row count (ROWCOUNT) and the column count (COLUMNCOUNT) that the server expects to return in a request. The default value is false. Values: true|false |
A tibble of desired StreamCat metrics
Selia Markley
df <- lc_get_nni(year='1987, 1990, 2005, 2017', aoi='cat,ws', comid='23783629,23794487,23812618') df <- lc_get_nni(year='2015', aoi='cat', comid='23783629', countOnly=TRUE) df <- lc_get_nni(comid='23783629', year='2011, 2012', aoi='ws')df <- lc_get_nni(year='1987, 1990, 2005, 2017', aoi='cat,ws', comid='23783629,23794487,23812618') df <- lc_get_nni(year='2015', aoi='cat', comid='23783629', countOnly=TRUE) df <- lc_get_nni(comid='23783629', year='2011, 2012', aoi='ws')
Function to return available LakeCat parameters using the StreamCat API.
lc_get_params(param = NULL)lc_get_params(param = NULL)
param |
List of available parameters in the API for the following options: name, areaofInterest, region, state, county. State and county return a data frame that includes FIPS codes, names and state abbreviations Syntax: param=<value1>,<value2> Values: name|area |
A list of all the current LakeCat values for a given parameter
Marc Weber
## Not run: params <- lc_get_params(param='variable_info') params <- lc_get_params(param='metric_names') params <- sc_get_params(param='categories') params <- lc_get_params(param='aoi') params <- lc_get_params(param='state') params <- lc_get_params(param='county') params <- sc_get_params(param='datasets') ## End(Not run)## Not run: params <- lc_get_params(param='variable_info') params <- lc_get_params(param='metric_names') params <- sc_get_params(param='categories') params <- lc_get_params(param='aoi') params <- lc_get_params(param='state') params <- lc_get_params(param='county') params <- sc_get_params(param='datasets') ## End(Not run)
Lookup function for a single COMID from S3 GeoParquet (optionally restricted to one HUC2). Queries one COMID from an S3-hosted, HUC2-partitioned GeoParquet dataset and returns an sf object. If 'huc2' is provided, only that partition is scanned (fastest). If not, the function tries a glob over all HUC2 partitions and falls back to a shallower pattern if needed. The function: - loads DuckDB httpfs (S3) extension, - pushes an equality filter on 'COMID' for row-group/file pruning, - converts WKB geometry to sf with the CRS you provide (default EPSG:4326).
lc_get_watershed( comid, huc2 = NA_character_, huc2_filter = NULL, bucket = "dmap-data-commons-ow", prefix = "data/streamcat/LakeCatWatersheds/", region = "us-east-1", install_missing = FALSE, keep_open = FALSE, verbose = TRUE, progress = TRUE, threads = 4, enable_object_cache = TRUE, skip_describe = FALSE, skip_counts = TRUE, sf_crs = 4326, retries = 5, retry_base_delay = 0.5, retry_max_delay = 8, url_style = c("path", "virtual_hosted"), s3_endpoint = NULL )lc_get_watershed( comid, huc2 = NA_character_, huc2_filter = NULL, bucket = "dmap-data-commons-ow", prefix = "data/streamcat/LakeCatWatersheds/", region = "us-east-1", install_missing = FALSE, keep_open = FALSE, verbose = TRUE, progress = TRUE, threads = 4, enable_object_cache = TRUE, skip_describe = FALSE, skip_counts = TRUE, sf_crs = 4326, retries = 5, retry_base_delay = 0.5, retry_max_delay = 8, url_style = c("path", "virtual_hosted"), s3_endpoint = NULL )
comid |
Scalar COMID to query (numeric or character, required). |
huc2 |
Optional two-digit HUC2 string (e.g., "01") to restrict search to one partition. |
huc2_filter |
Optional character vector of HUC2s to read (e.g., c("01","05")) for multi-partition pruning. |
bucket |
Character(1). S3 bucket (default "dmap-data-commons-ow"). |
prefix |
Character(1). S3 prefix under the bucket (default "data/streamcat/LakeCatWatersheds/"). |
region |
Character(1). S3 region (default "us-east-1"). |
install_missing |
Logical. Install missing packages (duckdb, DBI, sf, wk) if needed (default FALSE). |
keep_open |
Logical. Keep the DuckDB connection open (default FALSE). Note: the connection is not returned. |
verbose |
Logical. Print progress messages (default TRUE). |
progress |
Logical. Show a simple progress bar (default TRUE). |
threads |
Integer or NULL. If set, 'PRAGMA threads' for DuckDB (parallelism). |
enable_object_cache |
Logical. Enable DuckDB object cache to speed repeated queries (default TRUE). |
skip_describe |
Logical. Skip DESCRIBE step (default FALSE). |
skip_counts |
Logical. Skip HUC2 counts step (default TRUE; no longer returned). |
sf_crs |
Integer or character. CRS for the output sf object (default 4326). |
retries |
Integer. Number of retries for transient S3/HTTP errors (default 5). |
retry_base_delay |
Numeric. Initial exponential backoff delay in seconds (default 0.5). |
retry_max_delay |
Numeric. Maximum backoff delay per attempt in seconds (default 8). |
url_style |
Character. S3 URL style used by DuckDB httpfs, one of "path" or "virtual_hosted". Passed to 'match.arg()', default "path". |
s3_endpoint |
Optional character(1). Custom S3 endpoint hostname (e.g., "s3.amazonaws.com"). NULL uses the default for the selected region. |
An sf object with zero or one+ rows (if multiple features share the same COMID).
Function to plot time series of nitrogen and phosphorus budgets for a given lake COMID. This function allows a user to return a time series of major inputs, outputs, and derived metrics of nitrogen and phosphorus. Plot is returned as an object
lc_plotnni(comid, include.nue = FALSE)lc_plotnni(comid, include.nue = FALSE)
comid |
Identifier of lake COMID user wants to plot NNI data for. Must be a character string with the COMID digit. Syntax: com=<COMID> |
include.nue |
Include time series of nitrogen use efficiency in the returned plot. The default value is false. Values: true|false |
Return plot as an object.
Selia Markley
## Not run: p <- lc_plotnni(comid='23794487') p <- lc_plotnni(comid='23794487', include.nue=TRUE) ## End(Not run)## Not run: p <- lc_plotnni(comid='23794487') p <- lc_plotnni(comid='23794487', include.nue=TRUE) ## End(Not run)
Function to retrieve a full metric name based on the short name using the StreamCat API.
sc_fullname(metric = NULL)sc_fullname(metric = NULL)
metric |
Short metric name Syntax: metric=value1 Values: metric |
A lookup of the full name for a given StreamCat metric
Marc Weber
fullname <- sc_fullname(metric='clay')fullname <- sc_fullname(metric='clay')
Function to return NHDPlusV2 COMIDS using either a dataframe with coordinates and a specified CRS or an sf object. The function generates a vector of COMID values a user can then pass to sc_get_data function
sc_get_comid(dd = NULL, xcoord = NULL, ycoord = NULL, crsys = NULL)sc_get_comid(dd = NULL, xcoord = NULL, ycoord = NULL, crsys = NULL)
dd |
Name of data frame object. Can be a simple data frame with coordinate columns in a known CRS or an sf points data frame |
xcoord |
The x coordinate column if using a raw data frame |
ycoord |
The y coordinate column if using a raw data frame |
crsys |
The epsg code if using a raw data frame |
A new sf data frame with a populated 'COMID' column
Marc Weber
## Not run: dd <- data.frame(x = c(-122.649,-100.348,-75.186,-106.675), y = c(45.085, 35.405,42.403,38.721)) comids <- sc_get_comid(dd, xcoord='x', ycoord='y', crsys=4269) dd <- sf::st_point_on_surface(sf::read_sf(system.file("shape/nc.shp", package="sf"))) comids <- sc_get_comid(dd) comids <- sc_get_comid(dd, xcoord='x', ycoord='y', crsys=4269) dd <- sf::read_sf(system.file("shape/nc.shp", package="sf")) comids <- sc_get_comid(dd) ## End(Not run)## Not run: dd <- data.frame(x = c(-122.649,-100.348,-75.186,-106.675), y = c(45.085, 35.405,42.403,38.721)) comids <- sc_get_comid(dd, xcoord='x', ycoord='y', crsys=4269) dd <- sf::st_point_on_surface(sf::read_sf(system.file("shape/nc.shp", package="sf"))) comids <- sc_get_comid(dd) comids <- sc_get_comid(dd, xcoord='x', ycoord='y', crsys=4269) dd <- sf::read_sf(system.file("shape/nc.shp", package="sf")) comids <- sc_get_comid(dd) ## End(Not run)
Function to return StreamCat catchment and watershed metrics using the StreamCat API. The function allows a user to get specific metric data aggregated by area of interest, returned by comid(s), hydroregion(s), state(s), or county(ies).
sc_get_data( comid = NULL, metric = NULL, aoi = NULL, showAreaSqKm = NULL, showPctFull = NULL, state = NULL, county = NULL, region = NULL, conus = NULL, countOnly = NULL )sc_get_data( comid = NULL, metric = NULL, aoi = NULL, showAreaSqKm = NULL, showPctFull = NULL, state = NULL, county = NULL, region = NULL, conus = NULL, countOnly = NULL )
comid |
Return metric information for specific COMIDs. Can be a comma-delimited list, a character vector,
or any object that can be coerced to a comma-delimited list with |
metric |
Name(s) of metrics to query. Must be character string with comma-delimited list of metrics,
or, if |
aoi |
Name(s) of areas of interest to query.
If a metric does not have data for a given AOI, no data is returned for that AOI.
Certain metrics that have no AOI specified for StreamCat need the AOI to be specified as Syntax: areaOfInterest=<value1>,<value2> Values: cat|ws|catrp100|wsrp100|other |
showAreaSqKm |
Return the area in square kilometers of a given area of interest. The default value is false. Values: true|false |
showPctFull |
Return the pctfull for each dataset. The default value is false. Values: true|false |
state |
Return metric information for COMIDs within a specific state. Use a state's abbreviation to
query for a given state. One of |
county |
Return metric information for COMIDs within a specific county.
Users must use the FIPS code, not county name, as a way to disambiguate counties.
One of |
region |
Return metric information for COMIDs within a specified hydroregion.
Hydroregions are specified using full name i.e. |
conus |
Return all COMIDs in the conterminous United States. Character string (Not case-sensitive) or logical.
The default value is false. If true, |
countOnly |
Return a CSV containing only the row count (ROWCOUNT) and the column count (COLUMNCOUNT) that the server expects to return in a request. The default value is false. Values: true|false |
A data frame of StreamCat metrics. If data are missing for all rows of a given metric, then the column for that metric will not exist. If data are missing for only some rows, then they will be specified with NA.
Marc Weber
## Not run: df <- sc_get_data(comid='179', aoi='cat', metric='fert') df <- sc_get_data(metric='pctgrs2006', aoi='ws', region='Region01') df <- sc_get_data(metric='pctwdwet2006', aoi='ws', county='41003') df <- sc_get_data(metric='pcturbmd2006', aoi='ws,rp100', comid='1337420') df <- sc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='179,1337,1337420') df <- sc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='179,1337,1337420', showAreaSqKm='true', showPctFull='true') df <- sc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='179,1337,1337420', countOnly='true') df <- sc_get_data(metric='thalwagdepth', comid='179,1337,1337420', aoi='other') df <- sc_get_data(metric='thalwagdepth', comid=c('179','1337','1337420'), aoi='other') df <- sc_get_data(comid='179', aoi='ws', metric='all') ## End(Not run)## Not run: df <- sc_get_data(comid='179', aoi='cat', metric='fert') df <- sc_get_data(metric='pctgrs2006', aoi='ws', region='Region01') df <- sc_get_data(metric='pctwdwet2006', aoi='ws', county='41003') df <- sc_get_data(metric='pcturbmd2006', aoi='ws,rp100', comid='1337420') df <- sc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='179,1337,1337420') df <- sc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='179,1337,1337420', showAreaSqKm='true', showPctFull='true') df <- sc_get_data(metric='pcturbmd2006,damdens', aoi='cat,ws', comid='179,1337,1337420', countOnly='true') df <- sc_get_data(metric='thalwagdepth', comid='179,1337,1337420', aoi='other') df <- sc_get_data(metric='thalwagdepth', comid=c('179','1337','1337420'), aoi='other') df <- sc_get_data(comid='179', aoi='ws', metric='all') ## End(Not run)
Function to filter StreamCat metrics metrics by category, area of interest, dataset or year. Use 'sc_get_params(categories)' or 'sc_get_params(datasets)' to see all the valid category or dataset options
sc_get_metric_names(category = NULL, aoi = NULL, year = NULL, dataset = NULL)sc_get_metric_names(category = NULL, aoi = NULL, year = NULL, dataset = NULL)
category |
Filter StreamCat metrics based on the metric category |
aoi |
Filter StreamCat metrics based on the area of interest |
year |
Filter StreamCat metrics based on a particular year or years |
dataset |
Filter StreamCat metrics based on the dataset name |
A dataframe of merics and description that match filter criteria
Marc Weber
## Not run: metrics <- sc_get_metric_names(category='Wildfire') metrics <- sc_get_metric_names(category = c('Deposition','Climate'), aoi=c('Cat','Ws')) metrics <- sc_get_metric_names(aoi='Other', dataset=c('Canal Density','Predicted Channel Widths Depths')) ## End(Not run)## Not run: metrics <- sc_get_metric_names(category='Wildfire') metrics <- sc_get_metric_names(category = c('Deposition','Climate'), aoi=c('Cat','Ws')) metrics <- sc_get_metric_names(aoi='Other', dataset=c('Canal Density','Predicted Channel Widths Depths')) ## End(Not run)
Function to get all NNI data available for a given year.
sc_get_nni( year, aoi = NULL, comid = NULL, showAreaSqKm = TRUE, state = NULL, county = NULL, region = NULL, conus = NULL, showPctFull = NULL, countOnly = NULL )sc_get_nni( year, aoi = NULL, comid = NULL, showAreaSqKm = TRUE, state = NULL, county = NULL, region = NULL, conus = NULL, showPctFull = NULL, countOnly = NULL )
year |
Years(s) of NNI metrics to query. Only valid NNI years are accepted (1987:2017) Syntax: year=<year1>,<year2> |
aoi |
Specify the area of interest described by a metric. By default, all available areas of interest for a given metric are returned. Syntax: areaOfInterest=<value1>,<value2> Values: catchment|watershed |
comid |
Return metric information for specific COMIDs Syntax: comid=<comid1>,<comid2> |
showAreaSqKm |
Return the area in square kilometers of a given area of interest. The default value is true. Values: true|false |
state |
Return metric information for COMIDs within a specific state. Use a state's abbreviation to query for a given state. Syntax: state=<state1>,<state2> |
county |
Return metric information for COMIDs within a specific county. Users must use the FIPS code, not county name, as a way to disambiguate counties. Syntax: county=<county1>,<county1> |
region |
Return metric information for COMIDs within a specified hydroregion. Syntax: region=<regionid1>,<regionid2> |
conus |
Return all COMIDs in the conterminous United States. The default value is false. Values: true|false |
showPctFull |
Return the pctfull for each dataset. The default value is false. Values: true|false |
countOnly |
Return a CSV containing only the row count (ROWCOUNT) and the column count (COLUMNCOUNT) that the server expects to return in a request. The default value is false. Values: true|false |
A tibble of desired StreamCat metrics
Selia Markley
## Not run: df <- sc_get_nni(year='1987, 1990, 2005, 2017', aoi='cat,ws', comid='179,1337,1337420') df <- sc_get_nni(year='2015', aoi='cat', comid='179', countOnly=TRUE) df <- sc_get_nni(comid='179', year='2011, 2012', aoi='ws') df <- sc_get_nni(year='2015, 2016, 2017', county='41003', aoi='ws') ## End(Not run)## Not run: df <- sc_get_nni(year='1987, 1990, 2005, 2017', aoi='cat,ws', comid='179,1337,1337420') df <- sc_get_nni(year='2015', aoi='cat', comid='179', countOnly=TRUE) df <- sc_get_nni(comid='179', year='2011, 2012', aoi='ws') df <- sc_get_nni(year='2015, 2016, 2017', county='41003', aoi='ws') ## End(Not run)
Function to return available StreamCat parameters using the StreamCat API.
sc_get_params(param = NULL)sc_get_params(param = NULL)
param |
List of available parameters in the API for the following options: name, areaofInterest, region, state, county. State and county return a data frame that includes FIPS codes, names and state abbreviations Syntax: param=<value1>,<value2> Values: name|area |
A list of all the current StreamCat values for a given parameter
Marc Weber
## Not run: params <- sc_get_params(param='variable_info') params <- sc_get_params(param='metric_names') params <- sc_get_params(param='categories') params <- sc_get_params(param='aoi') params <- sc_get_params(param='state') params <- sc_get_params(param='county') params <- sc_get_params(param='datasets') ## End(Not run)## Not run: params <- sc_get_params(param='variable_info') params <- sc_get_params(param='metric_names') params <- sc_get_params(param='categories') params <- sc_get_params(param='aoi') params <- sc_get_params(param='state') params <- sc_get_params(param='county') params <- sc_get_params(param='datasets') ## End(Not run)
Function to plot time series of nitrogen and phosphorus budgets for a given stream COMID. This function allows a user to return a time series of major inputs, outputs, and derived metrics of nitrogen and phosphorus. Plot is returned as an object
sc_plotnni(comid, include.nue = FALSE, include.inset = TRUE)sc_plotnni(comid, include.nue = FALSE, include.inset = TRUE)
comid |
Identifier of stream COMID user wants to plot NNI data for. Must be a character string with the COMID digit. Syntax: com=<COMID> |
include.nue |
Include time series of nitrogen use efficiency in the returned plot. The default value is false. Values: true|false |
include.inset |
Include inset map that shows the location of the COMID and its basin. The default value is true. Values: true|false |
Return plot as an object.
Selia Markley
## Not run: p <- sc_plotnni(comid='1337420') p <- sc_plotnni(comid='1337420', include.nue=TRUE) p <- sc_plotnni(comid='1337420', include.inset=FALSE) ## End(Not run)## Not run: p <- sc_plotnni(comid='1337420') p <- sc_plotnni(comid='1337420', include.nue=TRUE) p <- sc_plotnni(comid='1337420', include.inset=FALSE) ## End(Not run)