Skip to content

Commit

Permalink
Merge pull request #406 from USEPA/dataretrieval_multiple_states
Browse files Browse the repository at this point in the history
TADA Dataretrieval multiple states
  • Loading branch information
cristinamullin committed Feb 22, 2024
2 parents b43331d + c8b4904 commit cb2183f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions R/DataDiscoveryRetrieval.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,21 @@ TADA_DataRetrieval <- function(startDate = "null",
project = "null",
providers = "null",
applyautoclean = TRUE) {
# Set query parameters

# Set query parameters
WQPquery <- list()
if (length(statecode) > 1) {
WQPquery <- c(WQPquery, statecode = list(statecode))
} else if (statecode != "null") {
WQPquery <- c(WQPquery, statecode = statecode)

if (!"null" %in% statecode) {
load(system.file("extdata", "statecodes_df.Rdata", package = "TADA"))
statecode <- as.character(statecode)
statecodes_sub <- statecodes_df %>% dplyr::filter(STUSAB %in% statecode)
statecd <- paste0("US:", statecodes_sub$STATE)
if (nrow(statecodes_sub) == 0) {
stop("State code is not valid. Check FIPS state/territory abbreviations.")
}
if (length(statecode) >= 1) {
WQPquery <- c(WQPquery, statecode = list(statecd))
}
}

if (length(huc) > 1) {
Expand Down

0 comments on commit cb2183f

Please sign in to comment.