Skip to contents

Create the assessment unit and monitoring location ref by utilizing an optional user-supplied crosswalk, AU/ML crosswalk from ATTAINS (if org has entered that data), and TADA_CreateATTAINSAUMLCrosswalk to match unassigned monitoring locations to assessment units.

Usage

TADA_CreateAUMLCrosswalk(
  .data,
  au_ref = NULL,
  org_id = "all",
  fill_ATTAINS_catch = FALSE,
  return_nearest = TRUE,
  batch_upload = FALSE,
  api_key = NULL
)

Arguments

.data

A dataframe created by TADA_DataRetrieval().

au_ref

Optional. A user-supplied df with the columns AssessmentUnitIdentifier, MonitoringLocationIdentifier and WaterType.

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".

fill_ATTAINS_catch

Boolean argument. Specifies whether catchment-based ATTAINS assessment unit data (EPA snapshot of NHDPlus HR catchments associated with entity submitted assessment unit features - points, lines, and polygons) should be queried and downloaded for the assessment units included in the USER-SUPPLIED au_ref. When fill_ATTAINS_catch = TRUE, the catchment data are included in the output. When fill_ATTAINS_catch = FALSE, catchment data are not included. Setting fill_ATTAINS_catch = TRUE, may increase the run time of the function significantly. Default is fill_ATTAINS_catch = FALSE.

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). This param applies only to WQP observations that do not have matches in the user-supplied ref or ATTAINS.

batch_upload

Boolean argument. When batch_upload = TRUE, an additional data frame which matches the format required for batch upload to ATTAINS is included in the output. When batch_upload = FALSE, this df is not included in the output. Default is batch_upload = FALSE. If you would like to add new monitoring location data links or retain existing ones in ATTAINS, you will need to run TADA_UpdateATTAINSAUMLCrosswalk on the ATTAINS_batchupload data frame from this function's output.

api_key

Optional character string. An api key for Expert Query web services. If not supplied, the default TADA api key will be used. For best performance, it is recommended that users obtain and use their own api key. Request an api key here: https://owapps.epa.gov/expertquery/api-documentation

Value

A list containing a modified TADA data frame with added ATTAINS columns and data frames for ATTAINS data and features for points, lines, polygons and catchments. When batch_upload = TRUE, the list will contain an additional data frame formatted for compatibility with ATTAINS batch upload for Monitoring_Stations.

Examples

if (FALSE) { # \dontrun{
# Load the example data
utils::data(Data_MT_MissoulaCounty)

# Example 1: Basic use with default settings
result <- TADA_CreateAUMLCrosswalk(Data_MT_MissoulaCounty)

# Example 2: Using a user-supplied crosswalk
user_crosswalk <- data.frame(
  AssessmentUnitIdentifier = c("AU1", "AU2"),
  MonitoringLocationIdentifier = c("ML1", "ML2"),
  WaterType = c("River", "Lake")
)
result <- TADA_CreateAUMLCrosswalk(
  Data_MT_MissoulaCounty,
  au_ref = user_crosswalk
)

# Example 3: Including ATTAINS catchment data
result <- TADA_CreateAUMLCrosswalk(
  Data_MT_MissoulaCounty,
  fill_ATTAINS_catch = TRUE
)

# Example 4: Preparing for batch upload
result <- TADA_CreateAUMLCrosswalk(
  Data_MT_MissoulaCounty,
  batch_upload = TRUE
)

# Example 5: Using multiple options together
org_id <- "EPA"
result <- TADA_CreateAUMLCrosswalk(
  Data_MT_MissoulaCounty,
  au_ref = user_crosswalk,
  org_id = org_id,
  fill_ATTAINS_catch = TRUE,
  return_nearest = FALSE,
  batch_upload = TRUE
)

# View the results
print(result$TADA_with_ATTAINS)
print(result$ATTAINS_catchments)
print(result$ATTAINS_batchupload)
} # }