Returns ATTAINS data for assessment unit identifiers provided by the user.
Arguments
- .data
A TADA data frame including including some results from monitoring locations already paired with assessment unit identifiers.
- au_ref
Required. A df containing the existing crosswalk of known AU and monitoring location identifier combinations. Can be created using TADA_GetATTAINSAUMLCrosswalk or provided by the user from an external file. Must contain the columns ATTAINS.MonitoringLocationIdentifier, and ATTAINS.AssessmentUnitIdentifier. The monitoring location identifiers must match those in the WQP, which may contain the organization and provider in the MonitoringLocationIdentifier.
- add_catch
Boolean argument. Specify whether catchment data should be queried and downloaded for the user-supplied assessment units. When add_catch = TRUE, the catchment data are included in the output. When add_catch = FALSE, catchment data are not included. Setting add_catch = TRUE, may increase the run time of the function significantly. Default is add_catch = FALSE.
Value
A modified TADA_DataRetrieval()
dataframe or list with additional
columns associated with the ATTAINS assessment unit data, and, if
fill_catchments = TRUE, an additional dataframe of the observations without
intersecting ATTAINS features.
Moreover, if return_sf = TRUE, this function will additionally return the
raw ATTAINS and catchment shapefile features associated with those
observations.
Details
This function can be used to fetch information for known assessment unit identifier/monitoring location combinations in order to provide data compatible with the results of TADA_CreateATTAINSAUMLCrosswalk for previously unidentified assessment unit identifier/monitoring location combinations.
Examples
if (FALSE) { # \dontrun{
# Example 1: Basic usage with default settings
# Assume `my_data` is a TADA data frame with some monitoring
# location results
# Assume `my_au_ref` is a data frame containing known AU and monitoring
# location combinations
result <- TADA_GetATTAINSByAUID(my_data, au_ref = my_au_ref)
# Example 2: Fetching ATTAINS data with catchment information
# Set `add_catch` to TRUE to include catchment data in the output
result_with_catch <- TADA_GetATTAINSByAUID(my_data,
au_ref = my_au_ref,
add_catch = TRUE
)
# Example 3: Handling empty data frames
# If the input data frame has no observations, the function returns an
# empty data frame with ATTAINS columns
empty_data <- data.frame()
empty_result <- TADA_GetATTAINSByAUID(empty_data, au_ref = my_au_ref)
# Example 4: Custom AU reference data from an external file
# Load AU reference data from a CSV file and use it in the function
au_ref_from_file <- read.csv("path/to/au_ref.csv")
result_with_file_au_ref <- TADA_GetATTAINSByAUID(my_data,
au_ref = au_ref_from_file
)
} # }