Create an ATTAINS AU–ML Crosswalk from WQP Monitoring Location IDs for New Point AUs
Source:R/ATTAINSCrosswalks.R
TADA_CreatePointAUs.RdBuild a distinct crosswalk between WQP Monitoring Locations and ATTAINS
Assessment Units. Missing or blank ATTAINS.AssessmentUnitIdentifier values
are filled from TADA.MonitoringLocationIdentifier, optionally prefixed
with auid_prefix. Existing non-missing, non-blank AUIDs are left unchanged.
Optionally, this function can also return either a df or a shp file containing
the point or multipoint geometry and its corresponding assessment unit identifier.
Usage
TADA_CreatePointAUs(
.data,
auid_prefix = NULL,
create_geo = FALSE,
download_geo = FALSE,
tada_df = FALSE
)Arguments
- .data
A data frame containing, at minimum:
TADA.MonitoringLocationIdentifier
If
create_geo = TRUE, the input must also contain:TADA.LatitudeMeasureTADA.LongitudeMeasureHorizontalCoordinateReferenceSystemDatumName
If missing water-type values need to be crosswalked, the input must also contain:
TADA.MonitoringLocationTypeName
Optional columns:
ATTAINS.AssessmentUnitIdentifierATTAINS.WaterType
- auid_prefix
Character or
NULL. If provided and non-empty, this prefix is added only to newly createdATTAINS.AssessmentUnitIdentifiervalues.- create_geo
Logical. If
TRUE, also create point geometry usingTADA_CreatePointAUGeometry().- download_geo
Logical. If
TRUE, write the geometry shapefile to the user's downloads folder.- tada_df
Logical. If
TRUE, append the geometry, ATTAINS.MonitoringLocationIdentifier, ATTAINS.AssessmentUnitIdentifier, and ATTAINS.WaterType columns to the existing TADA df (.data) for mapping purposes. create_geo must equalTRUEin order to use tada_df equalsTRUE.
Value
If create_geo = FALSE, a distinct crosswalk data frame containing:
ATTAINS.MonitoringLocationIdentifierATTAINS.AssessmentUnitIdentifierATTAINS.WaterType
If create_geo = TRUE, a named list with:
crosswalkgeometry
If tada_df = TRUE, a named list with:
-crosswalk
TADA_with_newAUs
If both create_geo = TRUE and tada_df = TRUE, a named list with:
crosswalkgeometryTADA_with_newAUs
Details
If ATTAINS.WaterType is missing or contains any blank values, the function
attempts to populate it by calling TADA_UpdateATTAINSWaterTypes()
internally with overwrite_existing = FALSE and validation = "none".
Missing or blank
ATTAINS.AssessmentUnitIdentifiervalues are replaced withTADA.MonitoringLocationIdentifier.If
auid_prefixis supplied and non-empty, it is used only for newly created AUIDs.ATTAINS.MonitoringLocationIdentifieris created fromTADA.MonitoringLocationIdentifier.ATTAINS.WaterTypeis not overwritten unless it is missing or blank.
Examples
if (FALSE) { # \dontrun{
testdat <- Data_TribalNations_Harmonized |>
dplyr::filter(OrganizationIdentifier == "BLCKFEET") |>
dplyr::slice_sample(n = 25)
testdat_newAUs <- TADA_CreatePointAUs(
testdat,
create_geo = TRUE,
tada_df = TRUE
)
TADA_ViewNewAUs(testdat_newAUs$tada_df)
} # }