From 2ab61a334288363354e06c35fffd35473fe33b6a Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Wed, 21 Jan 2026 14:53:56 -0600 Subject: [PATCH 1/7] messing around with water use --- DESCRIPTION | 3 +- NAMESPACE | 1 + R/readNWISunit.R | 30 +---- R/read_waterdata_use.R | 138 +++++++++++++++++++++++ R/walk_pages.R | 3 +- man/readNWISuse.Rd | 26 ----- man/read_waterdata_use_data.Rd | 90 +++++++++++++++ tests/testthat/tests_userFriendly_fxns.R | 50 ++++---- vignettes/Status.Rmd | 7 +- vignettes/dataRetrieval.Rmd | 20 ++-- vignettes/tutorial.Rmd | 2 +- 11 files changed, 275 insertions(+), 95 deletions(-) create mode 100644 R/read_waterdata_use.R create mode 100644 man/read_waterdata_use_data.Rd diff --git a/DESCRIPTION b/DESCRIPTION index e61e5727c..9b9c653d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,7 +55,8 @@ Imports: jsonlite, httr2, whisker, - sf + sf, + data.table Suggests: covr, dplyr, diff --git a/NAMESPACE b/NAMESPACE index 11b2921a1..8f3a68cd4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -57,6 +57,7 @@ export(read_waterdata_monitoring_location) export(read_waterdata_parameter_codes) export(read_waterdata_samples) export(read_waterdata_ts_meta) +export(read_waterdata_use_data) export(renameNWISColumns) export(setAccess) export(stateCd) diff --git a/R/readNWISunit.R b/R/readNWISunit.R index 387f08985..8083652f3 100644 --- a/R/readNWISunit.R +++ b/R/readNWISunit.R @@ -711,36 +711,18 @@ readNWISstat <- function(siteNumbers, parameterCd, startDate = "", endDate = "", #' County and state fields will be included as appropriate. #' #' @export -#' @examplesIf is_dataRetrieval_user() -#' \donttest{ -#' # All data for a county -#' allegheny <- readNWISuse(stateCd = "Pennsylvania", countyCd = "Allegheny") -#' -#' # Data for an entire state for certain years -#' ohio <- readNWISuse(years = c(2000, 2005, 2010), stateCd = "OH", countyCd = NULL) -#' -#' # Data for an entire state, county by county -#' pr <- readNWISuse(years = c(2000, 2005, 2010), stateCd = "PR", countyCd = "ALL") -#' -#' # All national-scale data, transforming data frame to named columns from named rows -#' national <- readNWISuse(stateCd = NULL, countyCd = NULL, transform = TRUE) -#' -#' # Washington, DC data -#' dc <- readNWISuse(stateCd = "DC", countyCd = NULL) -#' -#' # data for multiple counties, with different input formatting -#' paData <- readNWISuse(stateCd = "42", countyCd = c("Allegheny County", "BUTLER", 1, "031")) -#' -#' # retrieving two specific categories for an entire state -#' ks <- readNWISuse(stateCd = "KS", countyCd = NULL, categories = c("IT", "LI")) -#' } readNWISuse <- function(stateCd, countyCd, years = "ALL", categories = "ALL", convertType = TRUE, transform = FALSE) { - message(new_nwis_message()) + + .Deprecated(new = "read_waterdata_use.", + package = "dataRetrieval", + msg = "NWIS servers are slated for decommission. Please migrate to read_waterdata_use.") + + countyID <- NULL countyCd <- countyCd[countyCd != ""] diff --git a/R/read_waterdata_use.R b/R/read_waterdata_use.R new file mode 100644 index 000000000..51fc7787c --- /dev/null +++ b/R/read_waterdata_use.R @@ -0,0 +1,138 @@ +#' Get USGS Daily Data +#' +#' @description USGS's National Water Availability Assessment Data Companion +#' (NWDC) offers web services that provide access to national-scale USGS +#' modeled water availability data underlying the National Water Availability +#' Assessment. More information at \url{https://water.usgs.gov/nwaa-data}. +#' +#' @export +#' @param model See model IDs on the NWDC data catalog page. +#' Options are : "wu-public-supply-wd", "wu-thermoelectric", "wu-irrigation-cu", +#' "wu-irrigation-wd", and "wu-public-supply-cu" +#' @param variable See variable IDs on the NWDC data catalog page. +#' @param location Options : huc12, huc10, huc8, huc6, huc4, huc2, countyCd, stateCd +#' Locations can be visualized with the Spatial Extent Viewer. Only one location +#' can be queried at a time. All data are returned on a HUC12 spatial resolution. +#' When a queried location contains more than the maximum number of HUC12s +#' allowed per page or file (defined under limit below), multiple pages or files +#' will be returned. All huc12, huc10, and countyCd location queries return a +#' single page or file. All huc2 location queries return multiple pages or files. +#' All other (huc8, huc6, huc4, stateCd) location queries may or may not return +#' multiple pages or files, depending on their size. +#' @param timeres Options : monthly, annualcy, annualwy. +#' @param startdate Format : YYYY (for annual data) or YYYY-MM (for monthly data) +#' @param enddate Format : YYYY (for annual data) or YYYY-MM (for monthly data) +#' @param intersection Options : overlap, envelop +#' @param limit Defines the number of HUC12s returned per page or file. +#' Queries of locations containing more than the below maximum value of HUC12s +#' will return multiple pages or files (see location above for details). +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' wu1 <- read_waterdata_use_data(model = "wu-public-supply-wd", +#' variable = c("pswdtot", "pswdgw", "pswdsw"), +#' location = "stateCd:RI", +#' startdate = "2020-01", +#' timeres = "monthly") +#' +#' wu2 <- read_waterdata_use_data(model = "wu-thermoelectric", +#' variable = c('tecufgw', 'tecufsw', 'tecuftot', +#' 'tewdfgw', 'tewdfsw', 'tewdftot', +#' 'tewdssw'), +#' location = "stateCd:RI", +#' startdate = "2020-01", +#' timeres = "monthly") +#' +#' wu3 <- read_waterdata_use_data(model = "wu-irrigation-cu", +#' variable = "irrcutot", +#' location = "stateCd:WI", +#' startdate = "2020-01", +#' timeres = "monthly") +#' +#' wu4 <- read_waterdata_use_data(model = "wu-irrigation-wd", +#' variable = c("irrwdtot", "irrwdgw", "irrwdsw"), +#' location = "huc2:04", +#' startdate = "2015", +#' timeres = "annualcy") +#' +#' wu5 <- read_waterdata_use_data(model = "wu-public-supply-cu", +#' variable = "pscutot", +#' location = "stateCd:WI", +#' startdate = "2020", +#' timeres = "annualwy") +#' } +read_waterdata_use_data <- function(model = NA_character_, + variable = NA_character_, + location = NA_character_, + timeres = NA_character_, + startdate = NA_character_, + enddate = NA_character_, + intersection = "overlap", + limit = 600){ + + args <- mget(names(formals())) + args <- Filter(Negate(anyNA), args) + format <- "json" + + baseURL <- httr2::request("https://api.water.usgs.gov/") |> + httr2::req_url_path_append("nwaa-data") |> + httr2::req_url_path_append("data") |> + httr2::req_user_agent(default_ua()) |> + httr2::req_headers(`Accept` = "application/json") |> + httr2::req_url_query(format = format ) |> + httr2::req_error(body = error_body) |> + httr2::req_timeout(seconds = 180) + + baseURL <- explode_query(baseURL, POST = FALSE, args, multi = "comma") + + message("Requesting:\n", baseURL$url) + if(format == "csv"){ + resp <- httr2::req_perform(baseURL) + body <- httr2::resp_body_string(resp) + df <- suppressMessages(data.table::fread(file = body, data.table = FALSE) ) + + } else { + resps <- httr2::req_perform_iterative(baseURL, + next_req = next_req_url_wu, + max_reqs = Inf, on_error = "stop") + + df <- data.frame() + + for(resp in resps){ + body <- httr2::resp_body_json(resp)[["data"]][[1]] + for(i in 1:length(body)){ + + df_i <- suppressWarnings(data.table::rbindlist(body[[i]], fill = TRUE)) |> + data.table::setDF() + df_i$location <- names(body[i]) + df <- rbind(df, df_i) + } + } + } + + attr(df, "request") <- baseURL + attr(df, "queryTime") <- Sys.time() + return(df) + +} + +next_req_url_wu <- function(resp, req){ + + body <- httr2::resp_body_json(resp) + + links <- body$metadata$links + if(any(sapply(links, function(x) x$rel) == "next")){ + next_index <- which(sapply(links, function(x) x$rel) == "next") + + next_url <- links[[next_index]][["href"]] + next_url <- gsub(pattern = "https://water.usgs.gov", + replacement = "https://api.water.usgs.gov", + x = next_url) + return(httr2::req_url(req = req, url = next_url)) + } else { + return(NULL) + } + +} + + diff --git a/R/walk_pages.R b/R/walk_pages.R index e83fcdb7c..b0a08d27c 100644 --- a/R/walk_pages.R +++ b/R/walk_pages.R @@ -15,7 +15,6 @@ walk_pages <- function(req){ df1 <- get_resp_data(resp) return_list <- rbind(return_list, df1) } - return(return_list) } @@ -106,7 +105,7 @@ get_csv <- function(req, limit){ if(httr2::resp_has_body(resp)){ return_list <- httr2::resp_body_string(resp) - df <- suppressMessages(readr::read_csv(file = return_list)) + df <- suppressMessages(data.table::fread(text = return_list, data.table = FALSE)) if(skip_geo){ df <- df[, names(df)[!names(df) %in% c("x", "y")]] } else { diff --git a/man/readNWISuse.Rd b/man/readNWISuse.Rd index db926c349..bbe4ecf5d 100644 --- a/man/readNWISuse.Rd +++ b/man/readNWISuse.Rd @@ -53,29 +53,3 @@ Retrieves water use data from USGS Water Use Data for the Nation. See \url{https://waterdata.usgs.gov/nwis/wu} for more information. All available use categories for the supplied arguments are retrieved. } -\examples{ -\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} -\donttest{ -# All data for a county -allegheny <- readNWISuse(stateCd = "Pennsylvania", countyCd = "Allegheny") - -# Data for an entire state for certain years -ohio <- readNWISuse(years = c(2000, 2005, 2010), stateCd = "OH", countyCd = NULL) - -# Data for an entire state, county by county -pr <- readNWISuse(years = c(2000, 2005, 2010), stateCd = "PR", countyCd = "ALL") - -# All national-scale data, transforming data frame to named columns from named rows -national <- readNWISuse(stateCd = NULL, countyCd = NULL, transform = TRUE) - -# Washington, DC data -dc <- readNWISuse(stateCd = "DC", countyCd = NULL) - -# data for multiple counties, with different input formatting -paData <- readNWISuse(stateCd = "42", countyCd = c("Allegheny County", "BUTLER", 1, "031")) - -# retrieving two specific categories for an entire state -ks <- readNWISuse(stateCd = "KS", countyCd = NULL, categories = c("IT", "LI")) -} -\dontshow{\}) # examplesIf} -} diff --git a/man/read_waterdata_use_data.Rd b/man/read_waterdata_use_data.Rd new file mode 100644 index 000000000..2c4503f08 --- /dev/null +++ b/man/read_waterdata_use_data.Rd @@ -0,0 +1,90 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_waterdata_use.R +\name{read_waterdata_use_data} +\alias{read_waterdata_use_data} +\title{Get USGS Daily Data} +\usage{ +read_waterdata_use_data( + model = NA_character_, + variable = NA_character_, + location = NA_character_, + timeres = NA_character_, + startdate = NA_character_, + enddate = NA_character_, + intersection = "overlap", + limit = 600 +) +} +\arguments{ +\item{model}{See model IDs on the NWDC data catalog page. +Options are : "wu-public-supply-wd", "wu-thermoelectric", "wu-irrigation-cu", +"wu-irrigation-wd", and "wu-public-supply-cu"} + +\item{variable}{See variable IDs on the NWDC data catalog page.} + +\item{location}{Options : huc12, huc10, huc8, huc6, huc4, huc2, countyCd, stateCd +Locations can be visualized with the Spatial Extent Viewer. Only one location +can be queried at a time. All data are returned on a HUC12 spatial resolution. +When a queried location contains more than the maximum number of HUC12s +allowed per page or file (defined under limit below), multiple pages or files +will be returned. All huc12, huc10, and countyCd location queries return a +single page or file. All huc2 location queries return multiple pages or files. +All other (huc8, huc6, huc4, stateCd) location queries may or may not return +multiple pages or files, depending on their size.} + +\item{timeres}{Options : monthly, annualcy, annualwy.} + +\item{startdate}{Format : YYYY (for annual data) or YYYY-MM (for monthly data)} + +\item{enddate}{Format : YYYY (for annual data) or YYYY-MM (for monthly data)} + +\item{intersection}{Options : overlap, envelop} + +\item{limit}{Defines the number of HUC12s returned per page or file. +Queries of locations containing more than the below maximum value of HUC12s +will return multiple pages or files (see location above for details).} +} +\description{ +USGS's National Water Availability Assessment Data Companion +(NWDC) offers web services that provide access to national-scale USGS +modeled water availability data underlying the National Water Availability +Assessment. More information at \url{https://water.usgs.gov/nwaa-data}. +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ +wu1 <- read_waterdata_use_data(model = "wu-public-supply-wd", + variable = c("pswdtot", "pswdgw", "pswdsw"), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") + +wu2 <- read_waterdata_use_data(model = "wu-thermoelectric", + variable = c('tecufgw', 'tecufsw', 'tecuftot', + 'tewdfgw', 'tewdfsw', 'tewdftot', + 'tewdssw'), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") + +wu3 <- read_waterdata_use_data(model = "wu-irrigation-cu", + variable = "irrcutot", + location = "stateCd:WI", + startdate = "2020-01", + timeres = "monthly") + +wu4 <- read_waterdata_use_data(model = "wu-irrigation-wd", + variable = c("irrwdtot", "irrwdgw", "irrwdsw"), + location = "huc2:04", + startdate = "2015", + timeres = "annualcy") + +wu5 <- read_waterdata_use_data(model = "wu-public-supply-cu", + variable = "pscutot", + location = "stateCd:WI", + startdate = "2020", + timeres = "annualwy") +} +\dontshow{\}) # examplesIf} +} diff --git a/tests/testthat/tests_userFriendly_fxns.R b/tests/testthat/tests_userFriendly_fxns.R index fa7783782..fd282758e 100644 --- a/tests/testthat/tests_userFriendly_fxns.R +++ b/tests/testthat/tests_userFriendly_fxns.R @@ -224,31 +224,31 @@ test_that("readNWISstat tests", { expect_gt(nrow(annualData), 2) }) -context("readNWISuse tests") -test_that("readNWISuse tests", { - testthat::skip_on_cran() - skip_on_ci() - dc <- readNWISuse( - years = c(2000, 2005, 2010), - stateCd = "DC", countyCd = NULL - ) - expect_true(nrow(dc) == 3) - expect_is(dc$state_cd, "character") - - ohio <- readNWISuse( - years = 2005, - stateCd = "OH", - countyCd = "ALL" - ) - expect_true(nrow(ohio) == 88) - - twoCounties <- readNWISuse( - years = 2010, - stateCd = "PA", - countyCd = c("Cambria", "Indiana") - ) - expect_true(nrow(twoCounties) == 2) -}) +# context("readNWISuse tests") +# test_that("readNWISuse tests", { +# testthat::skip_on_cran() +# skip_on_ci() +# dc <- readNWISuse( +# years = c(2000, 2005, 2010), +# stateCd = "DC", countyCd = NULL +# ) +# expect_true(nrow(dc) == 3) +# expect_is(dc$state_cd, "character") +# +# ohio <- readNWISuse( +# years = 2005, +# stateCd = "OH", +# countyCd = "ALL" +# ) +# expect_true(nrow(ohio) == 88) +# +# twoCounties <- readNWISuse( +# years = 2010, +# stateCd = "PA", +# countyCd = c("Cambria", "Indiana") +# ) +# expect_true(nrow(twoCounties) == 2) +# }) context("state tests") test_that("state county tests", { diff --git a/vignettes/Status.Rmd b/vignettes/Status.Rmd index 9cf91c27d..d32d83033 100644 --- a/vignettes/Status.Rmd +++ b/vignettes/Status.Rmd @@ -44,10 +44,10 @@ df <- data.frame( "readNWISmeas", "readNWISdata", "readNWISuv", + "readNWISuse", "readNWISrating", "readNWISstat", "readNWISpeak", - "readNWISuse", "whatNWISdata" ), New = c( @@ -60,10 +60,11 @@ df <- data.frame( "read_waterdata_field_measurements", "read_waterdata", "read_waterdata_continuous", - rep("", 5) + "read_waterdata_use_data", + rep("", 4) ), "Available on (branch)" = c(rep("main (CRAN)", 8), - "develop", rep("", 5)) + "develop", "develop", rep("", 4)) ) knitr::kable(df, col.names = c("WaterServices (legacy) function", "Water Data (new) function", "Available on (branch name)")) diff --git a/vignettes/dataRetrieval.Rmd b/vignettes/dataRetrieval.Rmd index 92623e0ae..aecc49158 100644 --- a/vignettes/dataRetrieval.Rmd +++ b/vignettes/dataRetrieval.Rmd @@ -75,7 +75,7 @@ Functions <- c( "read_waterdata_field_measurements", "readNWISpeak", "read_waterdata_field_measurements", - "readNWISuse", + "read_waterdata_water_data", "readNWISstat", "read_waterdata_parameter_codes", "read_waterdata_monitoring_location", @@ -123,7 +123,8 @@ Source <- c("USGS Water Data API", "USGS Water Data API", "NWIS", "USGS Water Data API", - rep("NWIS",2), + "USGS Water Data API", + "NWIS", "USGS Water Data API", "USGS Water Data API", "USGS Samples Data", @@ -412,20 +413,13 @@ surfaceData <- read_waterdata_field_measurements(monitoring_location_id = "USGS- ## Water Use Data -Retrieves water use data from USGS Water Use Data for the Nation. See [https://waterdata.usgs.gov/nwis/wu](https://waterdata.usgs.gov/nwis/wu) for more information. All available use categories for the supplied arguments are retrieved. +Retrieves water use data from USGS Water Use Data for the Nation. See for more information. ```{r eval=FALSE} -allegheny <- readNWISuse( - stateCd = "Pennsylvania", - countyCd = "Allegheny" -) +allegheny <- read_waterdata_use_data(location = "countyCd:42003", + model = "wu-public-supply-wd", + variable = c("pswdtot", "pswdgw", "pswdsw")) - -national <- readNWISuse( - stateCd = NULL, - countyCd = NULL, - transform = TRUE -) ``` ## Statistics Data diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd index 825ffbde1..cb5d68f29 100644 --- a/vignettes/tutorial.Rmd +++ b/vignettes/tutorial.Rmd @@ -114,7 +114,7 @@ There are many types of data available from `dataRetrieval`. To understand how t |stat|`readNWISstat`| Site statistics | None yet | |rating|`readNWISrating`| Rating curves| None yet | |peak|`readNWISpeak`|Peak flow| None yet | -|use|`readNWISuse`|Water Use| None yet | +|use|`readNWISuse`|Water Use| `read_waterdata_use_data` | |meas|`readNWISmeas`|Discrete surface water| `read_waterdata_field_measurements`| | | `readNWISdata` | General data import | `read_waterdata` | From e70ff54de0f753b210ce18adb7b4d7bdd476fe90 Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Thu, 22 Jan 2026 12:13:52 -0600 Subject: [PATCH 2/7] Just use csv, it's a little faster --- R/read_waterdata_use.R | 62 +++++++++-------------- man/read_waterdata_continuous.Rd | 2 +- man/read_waterdata_daily.Rd | 4 +- man/read_waterdata_field_measurements.Rd | 4 +- man/read_waterdata_latest_continuous.Rd | 2 +- man/read_waterdata_latest_daily.Rd | 4 +- man/read_waterdata_monitoring_location.Rd | 40 +++++++-------- man/read_waterdata_ts_meta.Rd | 4 +- 8 files changed, 55 insertions(+), 67 deletions(-) diff --git a/R/read_waterdata_use.R b/R/read_waterdata_use.R index 51fc7787c..ba4c07d6b 100644 --- a/R/read_waterdata_use.R +++ b/R/read_waterdata_use.R @@ -72,7 +72,8 @@ read_waterdata_use_data <- function(model = NA_character_, args <- mget(names(formals())) args <- Filter(Negate(anyNA), args) - format <- "json" + + format <- "csv" baseURL <- httr2::request("https://api.water.usgs.gov/") |> httr2::req_url_path_append("nwaa-data") |> @@ -86,29 +87,16 @@ read_waterdata_use_data <- function(model = NA_character_, baseURL <- explode_query(baseURL, POST = FALSE, args, multi = "comma") message("Requesting:\n", baseURL$url) - if(format == "csv"){ - resp <- httr2::req_perform(baseURL) - body <- httr2::resp_body_string(resp) - df <- suppressMessages(data.table::fread(file = body, data.table = FALSE) ) - - } else { - resps <- httr2::req_perform_iterative(baseURL, - next_req = next_req_url_wu, - max_reqs = Inf, on_error = "stop") - - df <- data.frame() - for(resp in resps){ - body <- httr2::resp_body_json(resp)[["data"]][[1]] - for(i in 1:length(body)){ + resps <- httr2::req_perform_iterative(baseURL, + next_req = next_req_url_wu_csv, + max_reqs = Inf, on_error = "stop") - df_i <- suppressWarnings(data.table::rbindlist(body[[i]], fill = TRUE)) |> - data.table::setDF() - df_i$location <- names(body[i]) - df <- rbind(df, df_i) - } - } - } + df <- resps |> + httr2::resps_successes() |> + httr2::resps_data(\(resp) data.table::fread(text = httr2::resp_body_string(resp), + data.table = FALSE, + colClasses = list(character = "huc12_id"))) attr(df, "request") <- baseURL attr(df, "queryTime") <- Sys.time() @@ -116,23 +104,23 @@ read_waterdata_use_data <- function(model = NA_character_, } -next_req_url_wu <- function(resp, req){ +next_req_url_wu_csv <- function(resp, req){ - body <- httr2::resp_body_json(resp) - - links <- body$metadata$links - if(any(sapply(links, function(x) x$rel) == "next")){ - next_index <- which(sapply(links, function(x) x$rel) == "next") - - next_url <- links[[next_index]][["href"]] - next_url <- gsub(pattern = "https://water.usgs.gov", - replacement = "https://api.water.usgs.gov", - x = next_url) - return(httr2::req_url(req = req, url = next_url)) - } else { - return(NULL) + headers <- httr2::resp_headers(resp) + if("link" %in% names(headers)){ + if(grepl(pattern = '\"next\"', headers$link)){ + next_url <- gsub(pattern = ".*<(.*)>.*", + replacement = "\\1", + x = headers$link) + next_url <- gsub(pattern = "https://water.usgs.gov", + replacement = "https://api.water.usgs.gov", + x = next_url) + return(httr2::req_url(req = req, url = next_url)) + } } - + return(NULL) } + + diff --git a/man/read_waterdata_continuous.Rd b/man/read_waterdata_continuous.Rd index e97db63bd..4542788d5 100644 --- a/man/read_waterdata_continuous.Rd +++ b/man/read_waterdata_continuous.Rd @@ -25,7 +25,7 @@ read_waterdata_continuous( Multiple monitoring_location_ids can be requested as a character vector.} -\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://help.waterdata.usgs.gov/codes-and-parameters/parameters}. +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. Multiple parameter_codes can be requested as a character vector.} diff --git a/man/read_waterdata_daily.Rd b/man/read_waterdata_daily.Rd index 043d6c7e2..44522f354 100644 --- a/man/read_waterdata_daily.Rd +++ b/man/read_waterdata_daily.Rd @@ -28,11 +28,11 @@ read_waterdata_daily( Multiple monitoring_location_ids can be requested as a character vector.} -\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://help.waterdata.usgs.gov/codes-and-parameters/parameters}. +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. Multiple parameter_codes can be requested as a character vector.} -\item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://help.waterdata.usgs.gov/code/stat_cd_nm_query?stat_nm_cd=\%25&fmt=html}. +\item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/statistic-codes/items}. Multiple statistic_ids can be requested as a character vector.} diff --git a/man/read_waterdata_field_measurements.Rd b/man/read_waterdata_field_measurements.Rd index 4df1dd454..cec758b01 100644 --- a/man/read_waterdata_field_measurements.Rd +++ b/man/read_waterdata_field_measurements.Rd @@ -31,7 +31,7 @@ read_waterdata_field_measurements( Multiple monitoring_location_ids can be requested as a character vector.} -\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://help.waterdata.usgs.gov/codes-and-parameters/parameters}. +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. Multiple parameter_codes can be requested as a character vector.} @@ -66,7 +66,7 @@ Only features that have a \code{last_modified} that intersects the value of date \item{observing_procedure}{Water measurement or water-quality observing procedure descriptions.} -\item{vertical_datum}{The datum used to determine altitude and vertical position at the monitoring location. \href{https://help.waterdata.usgs.gov/code/alt_datum_cd_query?fmt=html}{A list of codes is available.}} +\item{vertical_datum}{The datum used to determine altitude and vertical position at the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/altitude-datums/items}.} \item{measuring_agency}{The agency performing the measurement.} diff --git a/man/read_waterdata_latest_continuous.Rd b/man/read_waterdata_latest_continuous.Rd index 90b78a4c2..8fea80e7d 100644 --- a/man/read_waterdata_latest_continuous.Rd +++ b/man/read_waterdata_latest_continuous.Rd @@ -27,7 +27,7 @@ read_waterdata_latest_continuous( Multiple monitoring_location_ids can be requested as a character vector.} -\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://help.waterdata.usgs.gov/codes-and-parameters/parameters}. +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. Multiple parameter_codes can be requested as a character vector.} diff --git a/man/read_waterdata_latest_daily.Rd b/man/read_waterdata_latest_daily.Rd index 330d7fb35..d6fc4e98e 100644 --- a/man/read_waterdata_latest_daily.Rd +++ b/man/read_waterdata_latest_daily.Rd @@ -28,11 +28,11 @@ read_waterdata_latest_daily( Multiple monitoring_location_ids can be requested as a character vector.} -\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://help.waterdata.usgs.gov/codes-and-parameters/parameters}. +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. Multiple parameter_codes can be requested as a character vector.} -\item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://help.waterdata.usgs.gov/code/stat_cd_nm_query?stat_nm_cd=\%25&fmt=html}. +\item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/statistic-codes/items}. Multiple statistic_ids can be requested as a character vector.} diff --git a/man/read_waterdata_monitoring_location.Rd b/man/read_waterdata_monitoring_location.Rd index ed8132e8a..118ede088 100644 --- a/man/read_waterdata_monitoring_location.Rd +++ b/man/read_waterdata_monitoring_location.Rd @@ -56,11 +56,11 @@ read_waterdata_monitoring_location( Multiple monitoring_location_ids can be requested as a character vector.} -\item{agency_code}{The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available \href{https://help.waterdata.usgs.gov/code/agency_cd_query?fmt=html}{at this link}.} +\item{agency_code}{The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/agency-codes/items}.} \item{agency_name}{The name of the agency that is reporting the data.} -\item{monitoring_location_number}{Each monitoring location in the USGS data base has a unique 8- to 15-digit identification number. Monitoring location numbers are assigned \href{https://help.waterdata.usgs.gov/faq/sites/do-station-numbers-have-any-particular-meaning}{based on this logic}.} +\item{monitoring_location_number}{Each monitoring location in the USGS data base has a unique 8- to 15-digit identification number.} \item{monitoring_location_name}{This is the official name of the monitoring location in the database. For well information this can be a district-assigned local number.} @@ -74,15 +74,15 @@ Multiple monitoring_location_ids can be requested as a character vector.} \item{state_name}{The name of the state or state equivalent in which the monitoring location is located.} -\item{county_code}{The code for the county or county equivalent (parish, borough, etc.) in which the monitoring location is located. \href{https://help.waterdata.usgs.gov/code/county_query?fmt=html}{A list of codes is available.}} +\item{county_code}{The code for the county or county equivalent (parish, borough, etc.) in which the monitoring location is located. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/counties/items}.} -\item{county_name}{The name of the county or county equivalent (parish, borough, etc.) in which the monitoring location is located. \href{https://help.waterdata.usgs.gov/code/county_query?fmt=html}{A list of codes is available.}} +\item{county_name}{The name of the county or county equivalent (parish, borough, etc.) in which the monitoring location is located. [A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/counties/items}.} \item{minor_civil_division_code}{Codes for primary governmental or administrative divisions of the county or county equivalent in which the monitoring location is located.} -\item{site_type_code}{A code describing the hydrologic setting of the monitoring location. \href{https://help.waterdata.usgs.gov/code/site_tp_query?fmt=html}{A list of codes is available.}} +\item{site_type_code}{A code describing the hydrologic setting of the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/site-types/items}.} -\item{site_type}{A description of the hydrologic setting of the monitoring location. \href{https://help.waterdata.usgs.gov/code/site_tp_query?fmt=html}{A list of codes is available.}} +\item{site_type}{A description of the hydrologic setting of the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/site-types/items}.} \item{hydrologic_unit_code}{The United States is divided and sub-divided into successively smaller hydrologic units which are classified into four levels: regions, sub-regions, accounting units, and cataloging units. The hydrologic units are arranged within each other, from the smallest (cataloging units) to the largest (regions). Each hydrologic unit is identified by a unique hydrologic unit code (HUC) consisting of two to eight digits based on the four levels of classification in the hydrologic unit system.} @@ -92,25 +92,25 @@ Multiple monitoring_location_ids can be requested as a character vector.} \item{altitude_accuracy}{Accuracy of the altitude, in feet. An accuracy of +/- 0.1 foot would be entered as “.1”. Many altitudes are interpolated from the contours on topographic maps; accuracies determined in this way are generally entered as one-half of the contour interval.} -\item{altitude_method_code}{Codes representing the method used to measure altitude. \href{https://help.waterdata.usgs.gov/code/alt_meth_cd_query?fmt=html}{A list of codes is available.}} +\item{altitude_method_code}{Codes representing the method used to measure altitude.} -\item{altitude_method_name}{The name of the the method used to measure altitude. \href{https://help.waterdata.usgs.gov/code/alt_meth_cd_query?fmt=html}{A list of codes is available.}} +\item{altitude_method_name}{The name of the the method used to measure altitude.} -\item{vertical_datum}{The datum used to determine altitude and vertical position at the monitoring location. \href{https://help.waterdata.usgs.gov/code/alt_datum_cd_query?fmt=html}{A list of codes is available.}} +\item{vertical_datum}{The datum used to determine altitude and vertical position at the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/altitude-datums/items}.} -\item{vertical_datum_name}{The datum used to determine altitude and vertical position at the monitoring location. \href{https://help.waterdata.usgs.gov/code/alt_datum_cd_query?fmt=html}{A list of codes is available.}} +\item{vertical_datum_name}{The datum used to determine altitude and vertical position at the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/altitude-datums/items}.} -\item{horizontal_positional_accuracy_code}{Indicates the accuracy of the latitude longitude values. \href{https://help.waterdata.usgs.gov/code/coord_acy_cd_query?fmt=html}{A list of codes is available.}} +\item{horizontal_positional_accuracy_code}{Indicates the accuracy of the latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-accuracy-codes/items}.} -\item{horizontal_positional_accuracy}{Indicates the accuracy of the latitude longitude values. \href{https://help.waterdata.usgs.gov/code/coord_acy_cd_query?fmt=html}{A list of codes is available.}} +\item{horizontal_positional_accuracy}{Indicates the accuracy of the latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-accuracy-codes/items}.} -\item{horizontal_position_method_code}{Indicates the method used to determine latitude longitude values. \href{https://help.waterdata.usgs.gov/code/coord_meth_cd_query?fmt=html}{A list of codes is available.}} +\item{horizontal_position_method_code}{Indicates the method used to determine latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-method-codes/items}.} -\item{horizontal_position_method_name}{Indicates the method used to determine latitude longitude values. \href{https://help.waterdata.usgs.gov/code/coord_meth_cd_query?fmt=html}{A list of codes is available.}} +\item{horizontal_position_method_name}{Indicates the method used to determine latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-method-codes/items}.} -\item{original_horizontal_datum}{Coordinates are published in EPSG:4326 / WGS84 / World Geodetic System 1984. This field indicates the original datum used to determine coordinates before they were converted. \href{https://help.waterdata.usgs.gov/code/coord_datum_cd_query?fmt=html}{A list of codes is available.}} +\item{original_horizontal_datum}{Coordinates are published in EPSG:4326 / WGS84 / World Geodetic System 1984. This field indicates the original datum used to determine coordinates before they were converted. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-datum-codes/items}.} -\item{original_horizontal_datum_name}{Coordinates are published in EPSG:4326 / WGS84 / World Geodetic System 1984. This field indicates the original datum used to determine coordinates before they were converted. \href{https://help.waterdata.usgs.gov/code/coord_datum_cd_query?fmt=html}{A list of codes is available.}} +\item{original_horizontal_datum_name}{Coordinates are published in EPSG:4326 / WGS84 / World Geodetic System 1984. This field indicates the original datum used to determine coordinates before they were converted. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-datum-codes/items}.} \item{drainage_area}{The area enclosed by a topographic divide from which direct surface runoff from precipitation normally drains by gravity into the stream above that point.} @@ -122,17 +122,17 @@ Multiple monitoring_location_ids can be requested as a character vector.} \item{construction_date}{Date the well was completed.} -\item{aquifer_code}{Local aquifers in the USGS water resources data base are identified by a geohydrologic unit code (a three-digit number related to the age of the formation, followed by a 4 or 5 character abbreviation for the geologic unit or aquifer name). \href{https://help.waterdata.usgs.gov/faq/groundwater/local-aquifer-description}{Additional information is available at this link.}} +\item{aquifer_code}{Local aquifers in the USGS water resources data base are identified by a geohydrologic unit code (a three-digit number related to the age of the formation, followed by a 4 or 5 character abbreviation for the geologic unit or aquifer name).} -\item{national_aquifer_code}{National aquifers are the principal aquifers or aquifer systems in the United States, defined as regionally extensive aquifers or aquifer systems that have the potential to be used as a source of potable water. Not all groundwater monitoring locations can be associated with a National Aquifer. Such monitoring locations will not be retrieved using this search criteria. \href{https://help.waterdata.usgs.gov/code/nat_aqfr_query?fmt=html}{A list of National aquifer codes and names is available.}} +\item{national_aquifer_code}{National aquifers are the principal aquifers or aquifer systems in the United States, defined as regionally extensive aquifers or aquifer systems that have the potential to be used as a source of potable water. Not all groundwater monitoring locations can be associated with a National Aquifer. Such monitoring locations will not be retrieved using this search criteria. A list of National aquifer codes and names is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/national-aquifer-codes/items}.} -\item{aquifer_type_code}{Groundwater occurs in aquifers under two different conditions. Where water only partly fills an aquifer, the upper surface is free to rise and decline. These aquifers are referred to as unconfined (or water-table) aquifers. Where water completely fills an aquifer that is overlain by a confining bed, the aquifer is referred to as a confined (or artesian) aquifer. When a confined aquifer is penetrated by a well, the water level in the well will rise above the top of the aquifer (but not necessarily above land surface). \href{https://help.waterdata.usgs.gov/faq/groundwater/local-aquifer-description}{Additional information is available at this link.}} +\item{aquifer_type_code}{Groundwater occurs in aquifers under two different conditions. Where water only partly fills an aquifer, the upper surface is free to rise and decline. These aquifers are referred to as unconfined (or water-table) aquifers. Where water completely fills an aquifer that is overlain by a confining bed, the aquifer is referred to as a confined (or artesian) aquifer. When a confined aquifer is penetrated by a well, the water level in the well will rise above the top of the aquifer (but not necessarily above land surface).} \item{well_constructed_depth}{The depth of the finished well, in feet below land surface datum. Note: Not all groundwater monitoring locations have information on Well Depth. Such monitoring locations will not be retrieved using this search criteria.} \item{hole_constructed_depth}{The total depth to which the hole is drilled, in feet below land surface datum. Note: Not all groundwater monitoring locations have information on Hole Depth. Such monitoring locations will not be retrieved using this search criteria.} -\item{depth_source_code}{A code indicating the source of water-level data. \href{https://help.waterdata.usgs.gov/code/water_level_src_cd_query?fmt=html}{A list of codes is available.}} +\item{depth_source_code}{A code indicating the source of water-level data.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: diff --git a/man/read_waterdata_ts_meta.Rd b/man/read_waterdata_ts_meta.Rd index 82cfce84d..088f1b8a4 100644 --- a/man/read_waterdata_ts_meta.Rd +++ b/man/read_waterdata_ts_meta.Rd @@ -39,7 +39,7 @@ read_waterdata_ts_meta( Multiple monitoring_location_ids can be requested as a character vector.} -\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://help.waterdata.usgs.gov/codes-and-parameters/parameters}. +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. Multiple parameter_codes can be requested as a character vector.} @@ -50,7 +50,7 @@ Available options are: geometry, time_series_id, unit_of_measure, parameter_name, parameter_code, statistic_id, hydrologic_unit_code, state_name, last_modified, begin, end, begin_utc, end_utc, computation_period_identifier, computation_identifier, thresholds, sublocation_identifier, primary, monitoring_location_id, web_description, parameter_description, parent_time_series_id. The default (\code{NA}) will return all columns of the data.} -\item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://help.waterdata.usgs.gov/code/stat_cd_nm_query?stat_nm_cd=\%25&fmt=html}. +\item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/statistic-codes/items}. Multiple statistic_ids can be requested as a character vector.} From b85db636da01f46fb8c13db2b8687aa7071d08bb Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Thu, 11 Jun 2026 12:35:42 -0500 Subject: [PATCH 3/7] updated docs --- man/read_waterdata_peaks.Rd | 2 +- man/read_waterdata_use_data.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/read_waterdata_peaks.Rd b/man/read_waterdata_peaks.Rd index 79e98b2c2..6cdae7958 100644 --- a/man/read_waterdata_peaks.Rd +++ b/man/read_waterdata_peaks.Rd @@ -41,7 +41,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, time_series_id, monitoring_location_id, parameter_code, peak_id, unit_of_measure, value, last_modified, time, water_year, year, month, day, time_of_day, peak_since. +geometry, time_series_id, monitoring_location_id, parameter_code, peak_id, unit_of_measure, value, last_modified, time, water_year, year, month, day, time_of_day, peak_since, qualifier. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint.} diff --git a/man/read_waterdata_use_data.Rd b/man/read_waterdata_use_data.Rd index 2c4503f08..7513cab2b 100644 --- a/man/read_waterdata_use_data.Rd +++ b/man/read_waterdata_use_data.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/read_waterdata_use.R \name{read_waterdata_use_data} \alias{read_waterdata_use_data} -\title{Get USGS Daily Data} +\title{Get USGS Water Use Data} \usage{ read_waterdata_use_data( model = NA_character_, From 682bbe00290fbb7418a71acaae537447fa248909 Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Tue, 23 Jun 2026 13:38:38 -0500 Subject: [PATCH 4/7] update wateruse --- NAMESPACE | 2 +- R/read_waterdata_use.R | 130 +++++++++++++----- man/read_waterdata_continuous.Rd | 2 +- man/read_waterdata_daily.Rd | 2 +- man/read_waterdata_field_measurements.Rd | 2 +- ...data_use_data.Rd => read_waterdata_use.Rd} | 70 +++++----- 6 files changed, 136 insertions(+), 72 deletions(-) rename man/{read_waterdata_use_data.Rd => read_waterdata_use.Rd} (54%) diff --git a/NAMESPACE b/NAMESPACE index 948abe69f..882472408 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -61,7 +61,7 @@ export(read_waterdata_samples) export(read_waterdata_stats_daterange) export(read_waterdata_stats_por) export(read_waterdata_ts_meta) -export(read_waterdata_use_data) +export(read_waterdata_use) export(renameNWISColumns) export(setAccess) export(stateCd) diff --git a/R/read_waterdata_use.R b/R/read_waterdata_use.R index fe0d7eb2d..b4d06ee88 100644 --- a/R/read_waterdata_use.R +++ b/R/read_waterdata_use.R @@ -9,6 +9,7 @@ #' @param model See model IDs on the NWDC data catalog page. #' Options are : "wu-public-supply-wd", "wu-thermoelectric", "wu-irrigation-cu", #' "wu-irrigation-wd", and "wu-public-supply-cu" +#' \url{https://water.usgs.gov/nwaa-data/data-catalog} #' @param variable See variable IDs on the NWDC data catalog page. #' @param location Options : huc12, huc10, huc8, huc6, huc4, huc2, countyCd, stateCd #' Locations can be visualized with the Spatial Extent Viewer. Only one location @@ -26,51 +27,104 @@ #' @param limit Defines the number of HUC12s returned per page or file. #' Queries of locations containing more than the below maximum value of HUC12s #' will return multiple pages or files (see location above for details). +#' @param attach_request logical, defaults to `r getOption("dataRetrieval.attach_request")`. +#' If set to `TRUE`, the full request sent to the Water Data API is attached +#' as an attribute to the data set. #' @examplesIf is_dataRetrieval_user() #' #' \donttest{ -#' wu1 <- read_waterdata_use_data(model = "wu-public-supply-wd", -#' variable = c("pswdtot", "pswdgw", "pswdsw"), -#' location = "stateCd:RI", -#' startdate = "2020-01", -#' timeres = "monthly") +#' wu1 <- read_waterdata_use(model = "wu-public-supply-wd", +#' variable = c("pswdtot", "pswdgw", "pswdsw"), +#' location = "stateCd:RI", +#' startdate = "2020-01", +#' timeres = "monthly") #' -#' wu2 <- read_waterdata_use_data(model = "wu-thermoelectric", -#' variable = c('tecufgw', 'tecufsw', 'tecuftot', -#' 'tewdfgw', 'tewdfsw', 'tewdftot', -#' 'tewdssw'), -#' location = "stateCd:RI", -#' startdate = "2020-01", -#' timeres = "monthly") +#' wu2 <- read_waterdata_use(model = "wu-thermoelectric", +#' variable = c('tecufgw', 'tecufsw', 'tecuftot', +#' 'tewdfgw', 'tewdfsw', 'tewdftot', +#' 'tewdssw'), +#' location = "stateCd:RI", +#' startdate = "2020-01", +#' timeres = "monthly") #' -#' wu3 <- read_waterdata_use_data(model = "wu-irrigation-cu", -#' variable = "irrcutot", -#' location = "stateCd:WI", -#' startdate = "2020-01", -#' timeres = "monthly") +#' wu3 <- read_waterdata_use(model = "wu-irrigation-cu", +#' variable = "irrcutot", +#' location = "stateCd:WI", +#' startdate = "2020-01", +#' timeres = "monthly") #' -#' wu4 <- read_waterdata_use_data(model = "wu-irrigation-wd", -#' variable = c("irrwdtot", "irrwdgw", "irrwdsw"), -#' location = "huc2:04", -#' startdate = "2015", -#' timeres = "annualcy") +#' wu4 <- read_waterdata_use(model = "wu-irrigation-wd", +#' variable = c("irrwdtot", "irrwdgw", "irrwdsw"), +#' location = "huc2:04", +#' startdate = "2015", +#' timeres = "annualcy") #' -#' wu5 <- read_waterdata_use_data(model = "wu-public-supply-cu", -#' variable = "pscutot", -#' location = "stateCd:WI", -#' startdate = "2020", -#' timeres = "annualwy") +#' wu5 <- read_waterdata_use(model = "wu-public-supply-cu", +#' variable = "pscutot", +#' location = "stateCd:WI", +#' startdate = "2020", +#' timeres = "annualwy") #' } -read_waterdata_use_data <- function(model = NA_character_, - variable = NA_character_, - location = NA_character_, - timeres = NA_character_, - startdate = NA_character_, - enddate = NA_character_, - intersection = "overlap", - limit = 600){ +read_waterdata_use <- function(model = NA_character_, + variable = NA_character_, + location = NA_character_, + timeres = NA_character_, + startdate = NA_character_, + enddate = NA_character_, + intersection = "overlap", + limit = 500, + attach_request = getOption("dataRetrieval.attach_request")){ + + match.arg(intersection, choices = c("overlap", "envelop"), several.ok = FALSE) + match.arg(model, choices = c("wu-public-supply-wd", + "wu-thermoelectric", + "wu-irrigation-cu", + "wu-irrigation-wd", + "wu-public-supply-cu"), several.ok = FALSE) + + match.arg(timeres, choices = c("monthly", "annualcy", "annualwy")) + + location_prefix <- sapply(strsplit(location, ":"), function(x) x[1]) + choices = c("huc12", "huc10", "huc8", "huc6", "huc4", "huc2", "countyCd", "stateCd") + + + if(!location_prefix %in% choices){ + stop("Invalid location argument.") + } + + if(limit > 500){ + limit <- 500 + message("limit was reset to 500 which is the maximum value for this service.") + } + + if(!is.character(variable)){ + stop("Invalid variable argument.") + } + + # Monthly needs XXXX-XX + if(timeres == "monthly"){ + if(!is.na(startdate) & !grepl("^[0-9]{4}-[0-9]{2}$", startdate, perl = TRUE)){ + stop("Invalid startdate argument.") + } + + if(!is.na(enddate) & !grepl("^[0-9]{4}-[0-9]{2}$", enddate, perl = TRUE)){ + stop("Invalid enddate argument.") + } + } else { # Annual needs XXXX + if(!is.na(startdate) & !grepl("^[0-9]{4}$", startdate, perl = TRUE)){ + stop("Invalid startdate argument.") + } + + if(!is.na(enddate) & !grepl("^[0-9]{4}$", enddate, perl = TRUE)){ + stop("Invalid enddate argument.") + } + } + args <- mget(names(formals())) + + args[["attach_request"]] <- NULL + args <- Filter(Negate(anyNA), args) format <- "csv" @@ -84,6 +138,8 @@ read_waterdata_use_data <- function(model = NA_character_, httr2::req_error(body = error_body) |> httr2::req_timeout(seconds = 180) + baseURL <- add_api_token(baseURL) + baseURL <- explode_query(baseURL, POST = FALSE, args, multi = "comma") message("Requesting:\n", baseURL$url) @@ -98,7 +154,9 @@ read_waterdata_use_data <- function(model = NA_character_, data.table = FALSE, colClasses = list(character = "huc12_id"))) - attr(df, "request") <- baseURL + if(attach_request){ + attr(df, "request") <- baseURL + } attr(df, "queryTime") <- Sys.time() return(df) diff --git a/man/read_waterdata_continuous.Rd b/man/read_waterdata_continuous.Rd index b35db8666..e722a5ede 100644 --- a/man/read_waterdata_continuous.Rd +++ b/man/read_waterdata_continuous.Rd @@ -34,7 +34,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, continuous_id, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. +geometry, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint. diff --git a/man/read_waterdata_daily.Rd b/man/read_waterdata_daily.Rd index ef3d7eede..9c0efdd08 100644 --- a/man/read_waterdata_daily.Rd +++ b/man/read_waterdata_daily.Rd @@ -41,7 +41,7 @@ Multiple statistic_ids can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, daily_id, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. +geometry, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint. diff --git a/man/read_waterdata_field_measurements.Rd b/man/read_waterdata_field_measurements.Rd index b9543526c..95271b34f 100644 --- a/man/read_waterdata_field_measurements.Rd +++ b/man/read_waterdata_field_measurements.Rd @@ -45,7 +45,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, field_measurement_id, field_measurements_series_id, field_visit_id, parameter_code, monitoring_location_id, observing_procedure_code, observing_procedure, value, unit_of_measure, time, qualifier, vertical_datum, approval_status, measuring_agency, last_modified, control_condition, measurement_rated. +geometry, field_measurements_series_id, reading_type, field_visit_id, parameter_code, monitoring_location_id, observing_procedure_code, observing_procedure, value, unit_of_measure, time, qualifier, vertical_datum, approval_status, measuring_agency, last_modified, control_condition, measurement_rated, year, month, day, time_of_day. The default (\code{NA}) will return all columns of the data.} \item{field_visit_id}{A universally unique identifier (UUID) for the field visit. Multiple measurements may be made during a single field visit.} diff --git a/man/read_waterdata_use_data.Rd b/man/read_waterdata_use.Rd similarity index 54% rename from man/read_waterdata_use_data.Rd rename to man/read_waterdata_use.Rd index 7513cab2b..c84c2f589 100644 --- a/man/read_waterdata_use_data.Rd +++ b/man/read_waterdata_use.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/read_waterdata_use.R -\name{read_waterdata_use_data} -\alias{read_waterdata_use_data} +\name{read_waterdata_use} +\alias{read_waterdata_use} \title{Get USGS Water Use Data} \usage{ -read_waterdata_use_data( +read_waterdata_use( model = NA_character_, variable = NA_character_, location = NA_character_, @@ -12,13 +12,15 @@ read_waterdata_use_data( startdate = NA_character_, enddate = NA_character_, intersection = "overlap", - limit = 600 + limit = 500, + attach_request = getOption("dataRetrieval.attach_request") ) } \arguments{ \item{model}{See model IDs on the NWDC data catalog page. Options are : "wu-public-supply-wd", "wu-thermoelectric", "wu-irrigation-cu", -"wu-irrigation-wd", and "wu-public-supply-cu"} +"wu-irrigation-wd", and "wu-public-supply-cu" +\url{https://water.usgs.gov/nwaa-data/data-catalog}} \item{variable}{See variable IDs on the NWDC data catalog page.} @@ -43,6 +45,10 @@ multiple pages or files, depending on their size.} \item{limit}{Defines the number of HUC12s returned per page or file. Queries of locations containing more than the below maximum value of HUC12s will return multiple pages or files (see location above for details).} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} } \description{ USGS's National Water Availability Assessment Data Companion @@ -54,37 +60,37 @@ Assessment. More information at \url{https://water.usgs.gov/nwaa-data}. \dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} \donttest{ -wu1 <- read_waterdata_use_data(model = "wu-public-supply-wd", - variable = c("pswdtot", "pswdgw", "pswdsw"), - location = "stateCd:RI", - startdate = "2020-01", - timeres = "monthly") +wu1 <- read_waterdata_use(model = "wu-public-supply-wd", + variable = c("pswdtot", "pswdgw", "pswdsw"), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") -wu2 <- read_waterdata_use_data(model = "wu-thermoelectric", - variable = c('tecufgw', 'tecufsw', 'tecuftot', - 'tewdfgw', 'tewdfsw', 'tewdftot', - 'tewdssw'), - location = "stateCd:RI", - startdate = "2020-01", - timeres = "monthly") +wu2 <- read_waterdata_use(model = "wu-thermoelectric", + variable = c('tecufgw', 'tecufsw', 'tecuftot', + 'tewdfgw', 'tewdfsw', 'tewdftot', + 'tewdssw'), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") -wu3 <- read_waterdata_use_data(model = "wu-irrigation-cu", - variable = "irrcutot", - location = "stateCd:WI", - startdate = "2020-01", - timeres = "monthly") +wu3 <- read_waterdata_use(model = "wu-irrigation-cu", + variable = "irrcutot", + location = "stateCd:WI", + startdate = "2020-01", + timeres = "monthly") -wu4 <- read_waterdata_use_data(model = "wu-irrigation-wd", - variable = c("irrwdtot", "irrwdgw", "irrwdsw"), - location = "huc2:04", - startdate = "2015", - timeres = "annualcy") +wu4 <- read_waterdata_use(model = "wu-irrigation-wd", + variable = c("irrwdtot", "irrwdgw", "irrwdsw"), + location = "huc2:04", + startdate = "2015", + timeres = "annualcy") -wu5 <- read_waterdata_use_data(model = "wu-public-supply-cu", - variable = "pscutot", - location = "stateCd:WI", - startdate = "2020", - timeres = "annualwy") +wu5 <- read_waterdata_use(model = "wu-public-supply-cu", + variable = "pscutot", + location = "stateCd:WI", + startdate = "2020", + timeres = "annualwy") } \dontshow{\}) # examplesIf} } From cc009c1c916ff2f00b931faaf0112c9ba6e9abd1 Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Tue, 23 Jun 2026 15:01:30 -0500 Subject: [PATCH 5/7] add tests --- R/readNWISunit.R | 2 +- tests/testthat/tests_wateruse.R | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/tests_wateruse.R diff --git a/R/readNWISunit.R b/R/readNWISunit.R index bdee1a123..0478f0b02 100644 --- a/R/readNWISunit.R +++ b/R/readNWISunit.R @@ -461,7 +461,7 @@ readNWISuse <- function(stateCd, convertType = TRUE, transform = FALSE) { - .Deprecated(new = "read_waterdata_use_data in development", + .Deprecated(new = "read_waterdata_use", package = "dataRetrieval", msg = "NWIS servers for water use have been decommission. New functions are being developed.") return(NULL) diff --git a/tests/testthat/tests_wateruse.R b/tests/testthat/tests_wateruse.R new file mode 100644 index 000000000..aa85eb8b6 --- /dev/null +++ b/tests/testthat/tests_wateruse.R @@ -0,0 +1,52 @@ +context("Water Use functions") + +test_that("Water Use retrievals working", { + testthat::skip_on_cran() + testthat::skip_on_ci() + + vars <- c("pswdtot", "pswdgw", "pswdsw") + wu1 <- read_waterdata_use(model = "wu-public-supply-wd", + variable = vars, + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") + + expect_all_true(paste0(vars, "_mgd") %in% names(wu1)) + + expect_error(read_waterdata_use(model = "wu-public-supply-wd", + variable = c("pswdtot", "pswdgw", "pswdsw"), + location = "stateCd:RI", + startdate = "2020", #wrong type of startdate + timeres = "monthly")) + + wu2 <- read_waterdata_use(model = "wu-thermoelectric", + variable = c('tecufgw'), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") + + expect_all_true(paste0("tecufgw", "_mgd") %in% names(wu2)) + + wu3 <- read_waterdata_use(model = "wu-irrigation-cu", + variable = "irrcutot", + location = "stateCd:WI", + startdate = "2020-01", + timeres = "monthly") + + expect_all_true(paste0("irrcutot", "_mgd") %in% names(wu3)) + + vars <- c("irrwdtot", "irrwdgw", "irrwdsw") + wu4 <- read_waterdata_use(model = "wu-irrigation-wd", + variable = vars, + location = "huc2:04", + startdate = "2015", + timeres = "annualcy") + expect_all_true(paste0(vars, "_mgd") %in% names(wu4)) + + wu5 <- read_waterdata_use(model = "wu-public-supply-cu", + variable = "pscutot", + location = "stateCd:WI", + startdate = "2020", + timeres = "annualwy") + expect_all_true(paste0("pscutot", "_mgd") %in% names(wu5)) +}) From 4c1d0c98672bf7226808d932264754d51d4d49b6 Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Tue, 23 Jun 2026 15:38:10 -0500 Subject: [PATCH 6/7] rename --- NAMESPACE | 2 +- R/read_waterdata_use.R | 81 +++++++++---------- _pkgdown.yml | 9 ++- ...read_waterdata_use.Rd => read_wateruse.Rd} | 64 +++++++-------- tests/testthat/tests_wateruse.R | 12 +-- 5 files changed, 84 insertions(+), 84 deletions(-) rename man/{read_waterdata_use.Rd => read_wateruse.Rd} (61%) diff --git a/NAMESPACE b/NAMESPACE index 1aba8ab50..ea42a034c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,7 +67,7 @@ export(read_waterdata_samples) export(read_waterdata_stats_daterange) export(read_waterdata_stats_por) export(read_waterdata_ts_meta) -export(read_waterdata_use) +export(read_wateruse) export(renameNWISColumns) export(setAccess) export(stateCd) diff --git a/R/read_waterdata_use.R b/R/read_waterdata_use.R index b4d06ee88..4b43a8a85 100644 --- a/R/read_waterdata_use.R +++ b/R/read_waterdata_use.R @@ -33,47 +33,47 @@ #' @examplesIf is_dataRetrieval_user() #' #' \donttest{ -#' wu1 <- read_waterdata_use(model = "wu-public-supply-wd", -#' variable = c("pswdtot", "pswdgw", "pswdsw"), -#' location = "stateCd:RI", -#' startdate = "2020-01", -#' timeres = "monthly") +#' wu1 <- read_wateruse(model = "wu-public-supply-wd", +#' variable = c("pswdtot", "pswdgw", "pswdsw"), +#' location = "stateCd:RI", +#' startdate = "2020-01", +#' timeres = "monthly") #' -#' wu2 <- read_waterdata_use(model = "wu-thermoelectric", -#' variable = c('tecufgw', 'tecufsw', 'tecuftot', -#' 'tewdfgw', 'tewdfsw', 'tewdftot', -#' 'tewdssw'), -#' location = "stateCd:RI", -#' startdate = "2020-01", -#' timeres = "monthly") -#' -#' wu3 <- read_waterdata_use(model = "wu-irrigation-cu", -#' variable = "irrcutot", -#' location = "stateCd:WI", -#' startdate = "2020-01", -#' timeres = "monthly") +#' wu2 <- read_wateruse(model = "wu-thermoelectric", +#' variable = c('tecufgw', 'tecufsw', 'tecuftot', +#' 'tewdfgw', 'tewdfsw', 'tewdftot', +#' 'tewdssw'), +#' location = "stateCd:RI", +#' startdate = "2020-01", +#' timeres = "monthly") #' -#' wu4 <- read_waterdata_use(model = "wu-irrigation-wd", -#' variable = c("irrwdtot", "irrwdgw", "irrwdsw"), -#' location = "huc2:04", -#' startdate = "2015", -#' timeres = "annualcy") -#' -#' wu5 <- read_waterdata_use(model = "wu-public-supply-cu", -#' variable = "pscutot", -#' location = "stateCd:WI", -#' startdate = "2020", -#' timeres = "annualwy") +#' wu3 <- read_wateruse(model = "wu-irrigation-cu", +#' variable = "irrcutot", +#' location = "stateCd:WI", +#' startdate = "2020-01", +#' timeres = "monthly") +#' +#' wu4 <- read_wateruse(model = "wu-irrigation-wd", +#' variable = c("irrwdtot", "irrwdgw", "irrwdsw"), +#' location = "huc2:04", +#' startdate = "2015", +#' timeres = "annualcy") +#' +#' wu5 <- read_wateruse(model = "wu-public-supply-cu", +#' variable = "pscutot", +#' location = "stateCd:WI", +#' startdate = "2020", +#' timeres = "annualwy") #' } -read_waterdata_use <- function(model = NA_character_, - variable = NA_character_, - location = NA_character_, - timeres = NA_character_, - startdate = NA_character_, - enddate = NA_character_, - intersection = "overlap", - limit = 500, - attach_request = getOption("dataRetrieval.attach_request")){ +read_wateruse <- function(model = NA_character_, + variable = NA_character_, + location = NA_character_, + timeres = NA_character_, + startdate = NA_character_, + enddate = NA_character_, + intersection = "overlap", + limit = 500, + attach_request = getOption("dataRetrieval.attach_request")){ match.arg(intersection, choices = c("overlap", "envelop"), several.ok = FALSE) match.arg(model, choices = c("wu-public-supply-wd", @@ -120,7 +120,6 @@ read_waterdata_use <- function(model = NA_character_, } } - args <- mget(names(formals())) args[["attach_request"]] <- NULL @@ -137,9 +136,7 @@ read_waterdata_use <- function(model = NA_character_, httr2::req_url_query(format = format ) |> httr2::req_error(body = error_body) |> httr2::req_timeout(seconds = 180) - - baseURL <- add_api_token(baseURL) - + baseURL <- explode_query(baseURL, POST = FALSE, args, multi = "comma") message("Requesting:\n", baseURL$url) diff --git a/_pkgdown.yml b/_pkgdown.yml index c9ff3b353..38223daef 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -88,7 +88,6 @@ reference: - read_waterdata_combined_meta - read_waterdata_ratings - read_waterdata_peaks - - read_waterdata_use - summarize_waterdata_samples - check_waterdata_sample_params - title: National Water Information System (NWIS) @@ -119,7 +118,7 @@ reference: - title: National Ground-Water Monitoring Network desc: Functions to retrieve NGWMN data. contents: - - read_ngwmn_water_levels + - read_ngwmn_water_level - read_ngwmn_sites - read_ngwmn_providers - read_ngwmn_well_construction @@ -130,6 +129,10 @@ reference: contents: - findNLDI - get_nldi_sources + - title: National Water Availability Assessment Data + desc: Functions to get Water Use data + contents: + - read_wateruse - title: Import data desc: Functions to import different data formats contents: @@ -164,4 +167,4 @@ reference: - getWebServiceData - is_dataRetrieval_user - checkWQPdates - - get_ogc_params \ No newline at end of file + - get_ogc_params diff --git a/man/read_waterdata_use.Rd b/man/read_wateruse.Rd similarity index 61% rename from man/read_waterdata_use.Rd rename to man/read_wateruse.Rd index c84c2f589..f475e0e5e 100644 --- a/man/read_waterdata_use.Rd +++ b/man/read_wateruse.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/read_waterdata_use.R -\name{read_waterdata_use} -\alias{read_waterdata_use} +\name{read_wateruse} +\alias{read_wateruse} \title{Get USGS Water Use Data} \usage{ -read_waterdata_use( +read_wateruse( model = NA_character_, variable = NA_character_, location = NA_character_, @@ -60,37 +60,37 @@ Assessment. More information at \url{https://water.usgs.gov/nwaa-data}. \dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} \donttest{ -wu1 <- read_waterdata_use(model = "wu-public-supply-wd", - variable = c("pswdtot", "pswdgw", "pswdsw"), - location = "stateCd:RI", - startdate = "2020-01", - timeres = "monthly") +wu1 <- read_wateruse(model = "wu-public-supply-wd", + variable = c("pswdtot", "pswdgw", "pswdsw"), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") -wu2 <- read_waterdata_use(model = "wu-thermoelectric", - variable = c('tecufgw', 'tecufsw', 'tecuftot', - 'tewdfgw', 'tewdfsw', 'tewdftot', - 'tewdssw'), - location = "stateCd:RI", - startdate = "2020-01", - timeres = "monthly") - -wu3 <- read_waterdata_use(model = "wu-irrigation-cu", - variable = "irrcutot", - location = "stateCd:WI", - startdate = "2020-01", - timeres = "monthly") +wu2 <- read_wateruse(model = "wu-thermoelectric", + variable = c('tecufgw', 'tecufsw', 'tecuftot', + 'tewdfgw', 'tewdfsw', 'tewdftot', + 'tewdssw'), + location = "stateCd:RI", + startdate = "2020-01", + timeres = "monthly") -wu4 <- read_waterdata_use(model = "wu-irrigation-wd", - variable = c("irrwdtot", "irrwdgw", "irrwdsw"), - location = "huc2:04", - startdate = "2015", - timeres = "annualcy") - -wu5 <- read_waterdata_use(model = "wu-public-supply-cu", - variable = "pscutot", - location = "stateCd:WI", - startdate = "2020", - timeres = "annualwy") +wu3 <- read_wateruse(model = "wu-irrigation-cu", + variable = "irrcutot", + location = "stateCd:WI", + startdate = "2020-01", + timeres = "monthly") + +wu4 <- read_wateruse(model = "wu-irrigation-wd", + variable = c("irrwdtot", "irrwdgw", "irrwdsw"), + location = "huc2:04", + startdate = "2015", + timeres = "annualcy") + +wu5 <- read_wateruse(model = "wu-public-supply-cu", + variable = "pscutot", + location = "stateCd:WI", + startdate = "2020", + timeres = "annualwy") } \dontshow{\}) # examplesIf} } diff --git a/tests/testthat/tests_wateruse.R b/tests/testthat/tests_wateruse.R index aa85eb8b6..a908de63f 100644 --- a/tests/testthat/tests_wateruse.R +++ b/tests/testthat/tests_wateruse.R @@ -5,7 +5,7 @@ test_that("Water Use retrievals working", { testthat::skip_on_ci() vars <- c("pswdtot", "pswdgw", "pswdsw") - wu1 <- read_waterdata_use(model = "wu-public-supply-wd", + wu1 <- read_wateruse(model = "wu-public-supply-wd", variable = vars, location = "stateCd:RI", startdate = "2020-01", @@ -13,13 +13,13 @@ test_that("Water Use retrievals working", { expect_all_true(paste0(vars, "_mgd") %in% names(wu1)) - expect_error(read_waterdata_use(model = "wu-public-supply-wd", + expect_error(read_wateruse(model = "wu-public-supply-wd", variable = c("pswdtot", "pswdgw", "pswdsw"), location = "stateCd:RI", startdate = "2020", #wrong type of startdate timeres = "monthly")) - wu2 <- read_waterdata_use(model = "wu-thermoelectric", + wu2 <- read_wateruse(model = "wu-thermoelectric", variable = c('tecufgw'), location = "stateCd:RI", startdate = "2020-01", @@ -27,7 +27,7 @@ test_that("Water Use retrievals working", { expect_all_true(paste0("tecufgw", "_mgd") %in% names(wu2)) - wu3 <- read_waterdata_use(model = "wu-irrigation-cu", + wu3 <- read_wateruse(model = "wu-irrigation-cu", variable = "irrcutot", location = "stateCd:WI", startdate = "2020-01", @@ -36,14 +36,14 @@ test_that("Water Use retrievals working", { expect_all_true(paste0("irrcutot", "_mgd") %in% names(wu3)) vars <- c("irrwdtot", "irrwdgw", "irrwdsw") - wu4 <- read_waterdata_use(model = "wu-irrigation-wd", + wu4 <- read_wateruse(model = "wu-irrigation-wd", variable = vars, location = "huc2:04", startdate = "2015", timeres = "annualcy") expect_all_true(paste0(vars, "_mgd") %in% names(wu4)) - wu5 <- read_waterdata_use(model = "wu-public-supply-cu", + wu5 <- read_wateruse(model = "wu-public-supply-cu", variable = "pscutot", location = "stateCd:WI", startdate = "2020", From f1d8510f88dfd15ce87eedbd6b42303b0eccb576 Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Tue, 23 Jun 2026 15:38:49 -0500 Subject: [PATCH 7/7] rename file --- R/{read_waterdata_use.R => read_wateruse.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename R/{read_waterdata_use.R => read_wateruse.R} (100%) diff --git a/R/read_waterdata_use.R b/R/read_wateruse.R similarity index 100% rename from R/read_waterdata_use.R rename to R/read_wateruse.R