Link catchment-based ATTAINS assessment unit data
(EPA snapshot of NHDPlus HR catchments associated with entity submitted
assessment unit features - points, lines, and polygons) to Water Quality
Portal observations, often imported via TADA_DataRetrieval(). This
function returns the objects that can be mapped in TADA_ViewATTAINS().
Check out the TADAModule2.Rmd for an example workflow. Note that
approximately 80% of state submitted assessment units in ATTAINS were
developed based on high res NHDPlus, so we are using that as the default.
The ATTAINS snapshot of NHDPlus HR catchments is not available for areas
that do not have existing Assessment Units in ATTAINS.
Usage
TADA_CreateATTAINSAUMLCrosswalk(
.data,
org_id = "all",
return_nearest = TRUE,
return_sf = TRUE
)Arguments
- .data
A dataframe created by
TADA_DataRetrieval()or the sf equivalent made byTADA_MakeSpatial().- org_id
ATTAINS organization identifier(s) as a character string. If populated, Monitoring Locations will only be matched to Assessment Units from the specified organization(s). A list of organization identifiers can be found by downloading the ATTAINS Domains Excel file: https://www.epa.gov/system/files/other-files/2025-02/domains_2025-02-25.xlsx. Organization identifiers are listed in the "OrgName" tab. The "code" column contains the organization identifiers that should be used for this param. When org_id = "all", the MonitoringLocationIdentifier/AssessmentUnitIdentifier matches from all organizations will be considered. When org_id = "none" or NULL, no crosswalk data from ATTAINS will be considered. The default is "all".
- return_nearest
If a WQP observation falls within more than one AU, return ONLY the nearest AU (return_nearest = TRUE), or all AUs (return_nearest = FALSE).
- return_sf
Whether to return the ATTAINS associated catchments, lines, points, and polygon shapefile objects along with the data frame(s). TRUE (yes, return list) or FALSE (no, do not return). All shapefile features are in WGS84 (crs = 4326). Defaults to TRUE.
Value
A modified TADA_DataRetrieval() dataframe or list with additional
columns associated with the ATTAINS assessment unit data.
Moreover, if return_sf = TRUE, this function will additionally return the
raw ATTAINS and catchment shapefile features associated with those
observations.
This function calculates and reports the distance, 'TADA.DistanceAway.Meters', between each WQP observation and intersecting ATTAINS features within its catchment. A TADA.DistanceAway.Meters value of 0 indicates that the WQP observation is directly on the associated ATTAINS point or line feature, or located inside the associated ATTAINS polygon.
Details
`ResultIdentifier' identifies rows that are the same observation but are linked to multiple ATTAINS assessment units. It is possible for a single TADA WQP observation to have multiple ATTAINS assessment units linked to it and subsequently more than one row of data.
If TADA_MakeSpatial has not yet been run, this function runs it which also adds another new column to the input dataframe, 'geometry', which allows for mapping and additional geospatial capabilities.
Please review the output of this function carefully, especially waterbody intersections (tributaries), lake/ocean coasts, and other areas with complex hydrology where imprecise WQP monitoring location coordinates can be problematic. Note that many WQP locations will not fall within the bounds of NHDPlus (estuaries, oceans). Manual adjustments and quality control checks are strongly encouraged. WQP monitoring location metadata may also be helpful for matching waterbody names with ATTAINS waterbody names instead of relying solely on the geospatial location (lat/long).
Examples
if (FALSE) { # \dontrun{
tada_data <- TADA_DataRetrieval(
startDate = "2018-05-01",
endDate = "2018-05-05",
characteristicName = "pH",
statecode = "VA",
applyautoclean = TRUE,
ask = FALSE
)
# note: these example ATTAINS data retrieval queries below may take a long
# time (10+ minutes) to run
tada_attains <- TADA_CreateATTAINSAUMLCrosswalk(tada_data,
return_sf = FALSE,
return_nearest = FALSE
)
tada_attains_sf <- TADA_CreateATTAINSAUMLCrosswalk(tada_data,
return_sf = TRUE,
return_nearest = TRUE
)
} # }