knitr::opts_chunk$set(echo = FALSE , results = 'asis' , warning = FALSE , message = FALSE)
The BCG calculator requires the inclusion of Index Name and Index Class fields in the input file (otherwise the R code won’t know which BCG rules to apply). The PNMR BCG model has three BCG classes based on gradient and elevation:
low gradient/lower elevation (LoGrad-LoElev)
higher gradient/lower elevation (HiGrad-LoElev)
higher gradient/higher elevation (HiGrad-HiElev)
During BCG model development, gradient and elevation information were derived from the following sources:
Gradient - NHDPlusV2 flowline slope (x 100) from the NHDPlusV2 Value-Added Attributes (VAA) table (McKay et a. 2016)
Elevation - USEPA StreamCat elevation, local catchment scale (Hill et al. 2016)
Elevation and gradient data are difficult for some users to access. We added this function to make that step easier. It utilizes R tools from StreamCatTools and nhdplusTools to populate elevation and % slope based on the latitude and longitude coordinates in the input file.
{width=80%}
The following fields are required:
SampleID or SiteID– unique identifier
Latitude
Longitude
EPSG
Datum for coordinates (as an EPSG code).
If not provided, this function will create this column for you and auto-populate it with the EPSG value "4269" (NAD83, North America); https://epsg.io/4269
If you named the required fields differently in your input file, it’s ok. Click on the drop-down menus. The list of fields in your input file will appear. Select the correct column headings.
All columns in the input file are carried over into the output file.
The StreamCat R tools that are used to match your sites with the NHDPlusV2 stream segment identifiers (COMIDs) do not have QC measures. At a minimum, we recommend the following checks:
Include waterbody name in your input file and check against ‘gnis_name’ in the output file (which is derived from the NHDPlusV2 dataset); if they don’t match, investigate.
If you have watershed area based on exact watershed delineations, include it in your input file and check it against WSAREASQKM (which is not based on exact delineations, but should be fairly close).
Depending on the size of your input file, this function may several minutes to run (e.g., 5-10 minutes). Be patient. There is a lot going on behind the scenes. If you streamline your input file and only include station information (vs. station + macroinvertebrate data), it will run faster. You can then use the ‘Merge Files’ function to join the macroinvertebrate + stations data.
The StreamCatTools function sc_get_comid
uses the nhdplusTools function
discover_nhdplus_id
which utilizes a
nearest neighbor search.
Using the nhdplusTools function get_flowline_index
will return results in a
table instead of a vector but will include a distance measure. The function
requires additional inputs and has a warning that it may fail when employed
over a wide area. Thus it was not practical to implement in this Shiny app.
Click here to download a test file.
Click here to download example R scripts and data (all functions).
Last updated 2023-06-08
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.