diff --git a/NAMESPACE b/NAMESPACE index e2c8ae1d..a9bd2095 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,7 +32,6 @@ export(readNWISgwl) export(readNWISmeas) export(readNWISpCode) export(readNWISpeak) -export(readNWISqw) export(readNWISrating) export(readNWISsite) export(readNWISstat) diff --git a/NEWS b/NEWS index 5223d455..2706f45b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ dataRetrieval 2.7.17 =================== * Fixed bug with server problems causing errors. +* Removed the function "readNWISqw" since the underlying data was removed. * Added message of service URL. * Removed the forced "empty returns" for WQP, since the WQP now has properly formatted empty returns. * Moved the column parsing to a dedicated function for WQP. diff --git a/R/constructNWISURL.R b/R/constructNWISURL.R index e7f84a33..ba09988a 100644 --- a/R/constructNWISURL.R +++ b/R/constructNWISURL.R @@ -1,11 +1,6 @@ #' Construct NWIS url for data retrieval #' -#' Imports data from NWIS web service. This function gets the data from here: -#' \url{https://nwis.waterdata.usgs.gov/nwis/qwdata} -#' A list of parameter codes can be found here: -#' \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes/} -#' A list of statistic codes can be found here: -#' \url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table} +#' Imports data from NWIS web service. #' #' @param siteNumbers string or vector of strings USGS site number. This is usually an 8 digit number #' @param parameterCd string or vector of USGS parameter code. This is usually an 5 digit number. @@ -17,7 +12,7 @@ #' This is usually 5 digits. Daily mean (00003) is the default. #' @param service string USGS service to call. Possible values are "dv" (daily values), #' "uv" (unit/instantaneous values), -#' "qw" (water quality data), "gwlevels" (groundwater),and "rating" (rating curve), +#' "gwlevels" (groundwater),and "rating" (rating curve), #' "peak", "meas" (discrete streamflow measurements), #' "stat" (statistics web service BETA). #' @param format string, can be "tsv" or "xml", and is only applicable for daily @@ -83,10 +78,8 @@ constructNWISURL <- function(siteNumbers, statType = "mean") { service <- match.arg(service, c( "dv", "uv", "iv", "iv_recent", "qw", "gwlevels", - "rating", "peak", "meas", "stat", "qwdata" - )) + "rating", "peak", "meas", "stat")) - service[service == "qw"] <- "qwdata" service[service == "meas"] <- "measurements" service[service == "uv"] <- "iv" @@ -110,59 +103,6 @@ constructNWISURL <- function(siteNumbers, baseURL <- drURL(service, Access = pkg.env$access) switch(service, - qwdata = { - if (multipleSites) { - searchCriteria <- "multiple_site_no" - url <- appendDrURL(baseURL, multiple_site_no = siteNumbers) - } else { - searchCriteria <- "search_site_no" - url <- appendDrURL(baseURL, - search_site_no = siteNumbers, - search_site_no_match_type = "exact" - ) - } - - multiplePcodes <- length(parameterCd) > 1 - - if (multiplePcodes) { - pCodes <- paste(parameterCd, collapse = ",") - url <- appendDrURL(url, - multiple_parameter_cds = pCodes, - param_cd_operator = "OR" - ) - } else { - url <- appendDrURL(url, - multiple_parameter_cds = parameterCd, - param_cd_operator = "AND" - ) - } - - searchCriteria <- paste(searchCriteria, "multiple_parameter_cds", sep = ",") - url <- appendDrURL(url, list_of_search_criteria = searchCriteria) - - - url <- paste(url, "group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd", - "column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file", - "TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0", - "format=rdb&rdb_qw_attributes=0&date_format=YYYY-MM-DD", - "rdb_compression=value", - sep = "&" - ) - if (expanded) { - url <- appendDrURL(url, qw_sample_wide = "0") - url <- gsub("rdb_qw_attributes=0", "rdb_qw_attributes=expanded", url) - } else { - url <- appendDrURL(url, qw_sample_wide = "separated_wide") - } - - if (nzchar(startDate)) { - url <- appendDrURL(url, begin_date = startDate) - } - - if (nzchar(endDate)) { - url <- appendDrURL(url, end_date = endDate) - } - }, rating = { ratingType <- match.arg(ratingType, c("base", "corr", "exsa")) url <- appendDrURL(baseURL, site_no = siteNumbers, file_type = ratingType) @@ -211,7 +151,7 @@ constructNWISURL <- function(siteNumbers, stop("Monthly and annual report types can only provide means") } - # make sure dates aren"t too specific for statReportType + # make sure dates aren't too specific for statReportType if (grepl("(?i)monthly", statReportType) && (length(unlist(gregexpr("-", startDate))) > 1 || length(unlist(gregexpr("-", endDate))) > 1)) { @@ -354,7 +294,7 @@ constructWQPURL <- function(siteNumbers, parameterCd, startDate, endDate, - legacy = FALSE) { + legacy = TRUE) { allPCode <- any(toupper(parameterCd) == "ALL") if(!allPCode){ diff --git a/R/dataRetrievals-package.R b/R/dataRetrievals-package.R index b3d5eca5..528b6fa5 100644 --- a/R/dataRetrievals-package.R +++ b/R/dataRetrievals-package.R @@ -32,7 +32,7 @@ Extended Documentation: https://doi-usgs.github.io/dataRetrieval") #' List of USGS parameter codes #' -#' Complete list of USGS parameter codes as of Dec. 20, 2021. +#' Complete list of USGS parameter codes as of Oct. 24, 2024. #' #' @name parameterCdFile #' @return parameterData data frame with information about USGS parameters. diff --git a/R/importRDB1.R b/R/importRDB1.R index 5e5838e0..5aa89389 100644 --- a/R/importRDB1.R +++ b/R/importRDB1.R @@ -75,14 +75,6 @@ #' #' unitData <- importRDB1(unitDataURL, asDateTime = TRUE) #' -#' qwURL <- constructNWISURL(c("04024430", "04024000"), -#' c("34247", "30234", "32104", "34220"), -#' "2010-11-03", "", "qw", -#' format = "rdb" -#' ) -#' -#' qwData <- importRDB1(qwURL, asDateTime = TRUE, tz = "America/Chicago") -#' #' iceSite <- "04024000" #' start <- "2015-11-09" #' end <- "2015-11-24" diff --git a/R/readNGWMNdata.R b/R/readNGWMNdata.R index 808c0ad7..a1382729 100644 --- a/R/readNGWMNdata.R +++ b/R/readNGWMNdata.R @@ -1,4 +1,4 @@ -#' Import data from the National Groundwater Monitoring Network \url{https://cida.usgs.gov/ngwmn/}. +#' Import data from the National Groundwater Monitoring Network. #' #' Only water level data and site locations and names are currently available through the web service. #' @param service char Service for the request - "observation" and "featureOfInterest" are implemented. @@ -95,7 +95,7 @@ readNGWMNdata <- function(service, ..., asDateTime = TRUE, tz = "UTC") { return(returnData) } -#' Retrieve groundwater levels from the National Ground Water Monitoring Network \url{https://cida.usgs.gov/ngwmn/}. +#' Retrieve groundwater levels from the National Ground Water Monitoring Network. #' #' @param siteNumbers character Vector of feature IDs formatted with agency code and site number #' separated by a period or semicolon, e.g. \code{USGS.404159100494601}. @@ -136,7 +136,7 @@ readNGWMNlevels <- function(siteNumbers, asDateTime = TRUE, tz = "UTC") { return(data) } -#' Retrieve site data from the National Ground Water Monitoring Network \url{https://cida.usgs.gov/ngwmn/}. +#' Retrieve site data from the National Ground Water Monitoring Network. #' #' @param siteNumbers character Vector of feature IDs formatted with agency code and site number #' separated by a period or semicolon, e.g. \code{USGS.404159100494601}. diff --git a/R/readNWISqw.R b/R/readNWISqw.R deleted file mode 100644 index f20b201a..00000000 --- a/R/readNWISqw.R +++ /dev/null @@ -1,191 +0,0 @@ -#' Raw Data Import for USGS NWIS QW Data -#' -#' Deprecated function. USGS NWIS QW services will be discontinued, when that happens -#' this function will be removed from dataRetrieval. Please use\code{\link{readWQPqw}} or -#' \code{\link{readWQPdata}} instead. -#' -#' As of March 11, 2024, NWIS discrete water quality services are "frozen": -#' any public data retrieval will not include any new data. -#' -#' Contact CompTools@usgs.gov with additional questions! -#' -#' @param siteNumbers character of USGS site numbers. This is usually an 8 digit number -#' @param parameterCd character that contains the code for a parameter -#' group, or a character vector of 5-digit parameter codes. See \bold{Details}. -#' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. -#' Default is "" which indicates -#' retrieval for the earliest possible record. Date arguments are always specified in local time. -#' @param endDate character ending date for data retrieval in the form YYYY-MM-DD. -#' Default is "" which indicates -#' retrieval for the latest possible record. Date arguments are always specified in local time. -#' @param expanded logical defaults to \code{TRUE}. If \code{TRUE}, retrieves -#' additional information. Expanded data includes -#' remark_cd (remark code), result_va (result value), val_qual_tx -#' (result value qualifier code), meth_cd (method code), -#' dqi_cd (data-quality indicator code), rpt_lev_va (reporting level), and -#' rpt_lev_cd (reporting level type). If \code{FALSE}, -#' only returns remark_cd (remark code) and result_va (result value). -#' Expanded = \code{FALSE} will not give -#' sufficient information for unbiased statistical analysis. -#' @param reshape logical, reshape the expanded data. If \code{TRUE}, then return -#' a wide data frame with all water-quality in a single row for each sample. -#' If \code{FALSE} (default), then return a long data frame with each water-quality result in a single row. This -#' argument is only applicable to expanded data. Data requested using \code{expanded=FALSE} -#' is always returned in the wide format. -#' @param tz character to set timezone attribute of dateTime. Default is "UTC", and converts the -#' date times to UTC, properly accounting for daylight savings times based on the -#' data's provided tz_cd column. -#' Possible values to provide are "America/New_York", "America/Chicago", -#' "America/Denver", "America/Los_Angeles", "America/Anchorage", as well as the -#' following which do not use daylight savings time: "America/Honolulu", -#' "America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". -#' See also \code{OlsonNames()} -#' for more information on time zones. -#' @keywords data import USGS web service -#' @return A data frame not including USGS data newer than March 11, 2024. -#' -#' @export -#' @seealso \code{\link{readWQPdata}}, \code{\link{whatWQPsites}}, -#' \code{\link{readWQPqw}}, \code{\link{constructNWISURL}} -readNWISqw <- function(siteNumbers, - parameterCd, - startDate = "", - endDate = "", - expanded = TRUE, - reshape = FALSE, - tz = "UTC") { - .Deprecated( - new = "readWQPqw", package = "dataRetrieval", - msg = nwis_message() - ) - - pgrp <- c( - "INF", "PHY", "INM", "INN", "NUT", "MBI", "BIO", "IMM", "IMN", "TOX", - "OPE", "OPC", "OOT", "RAD", "XXX", "SED", "POP", - "ISO", "OTH", "HAB" - ) - - if (any(parameterCd == "all") || any(parameterCd == "All")) { - siteNumbers <- paste(siteNumbers, collapse = ",") - url <- paste0( - "https://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no= ", siteNumbers, - "&sort_key=site_no&group_key=NONE&inventory_output=0", - "&begin_date=", startDate, "&end_date=", endDate, - "&TZoutput=0", - "&radio_parm_cds=all_parm_cds&qw_attributes=0&format=rdb", - "&qw_sample_wide=0&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD", - "&rdb_compression=value&list_of_search_criteria=multiple_site_no" - ) - } else if (all(parameterCd %in% pgrp)) { - siteNumbers <- paste(siteNumbers, collapse = ",") - groups <- paste(parameterCd, collapse = ",") - url <- paste0( - "https://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=", siteNumbers, - "&sort_key=site_no&group_key=NONE&inventory_output=0", - "&begin_date=", startDate, "&end_date=", endDate, - "&TZoutput=0¶m_group=", groups, - "&qw_attributes=0&format=rdb", - "&qw_sample_wide=0&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD", - "&rdb_compression=value&list_of_search_criteria=multiple_site_no" - ) - } else { - url <- constructNWISURL(siteNumbers, - parameterCd, - startDate, - endDate, "qw", - expanded = expanded - ) - } - - data <- importRDB1(url, asDateTime = TRUE, tz = tz) - - url <- attr(data, "url") - comment <- attr(data, "comment") - queryTime <- attr(data, "queryTime") - header <- attr(data, "headerInfo") - - if (reshape) { - if (expanded) { - columnsToMelt <- c( - "agency_cd", "site_no", "sample_dt", "sample_tm", - "sample_end_dt", "sample_end_tm", "sample_start_time_datum_cd", "tm_datum_rlbty_cd", - "parm_cd", "startDateTime", "endDateTime", "coll_ent_cd", "medium_cd", "project_cd", - "aqfr_cd", "tu_id", "body_part_id", "hyd_cond_cd", "samp_type_cd", - "hyd_event_cd", "sample_lab_cm_tx", "tz_cd", "startDateTime", "endDateTime", - "sample_start_time_datum_cd_reported", "sample_end_time_datum_cd_reported" - ) - measureCols <- names(data)[!(names(data) %in% columnsToMelt)] - columnsToMelt <- names(data)[(names(data) %in% columnsToMelt)] - dataWithPcodes <- data[data$parm_cd != "", ] - if (sum(data$parm_cd == "", na.rm = TRUE)> 0) { - warning("Some or all data returned without pCodes, those data will not be included in reshape") - } - original_start_dates <- dataWithPcodes$startDateTime - original_end_dates <- dataWithPcodes$endDateTime - - parameterCd <- unique(dataWithPcodes$parm_cd) - idcols <- names(dataWithPcodes)[!(names(dataWithPcodes) %in% c(measureCols, "parm_cd"))] - - dataWithPcodes[, idcols] <- lapply(dataWithPcodes[, idcols], function(x) as.factor(x)) - dataWithPcodes[, idcols] <- lapply(dataWithPcodes[, idcols], function(x) addNA(x)) - - wide2 <- stats::reshape(dataWithPcodes, - idvar = idcols, - timevar = "parm_cd", - v.names = measureCols, - direction = "wide" - ) - names(wide2) <- gsub("\\.", "_", names(wide2)) - idcols_factors <- idcols[unname(sapply(wide2[idcols], class) == "factor")] - idcols_dates <- idcols[grep("_dt", idcols)] - - wide2[, idcols_factors] <- sapply(wide2[, idcols_factors], as.character) - wide2[, idcols_dates] <- lapply(wide2[, idcols_dates], as.Date) - other_dates <- names(wide2)[grep("_dt", names(wide2))] - other_dates <- other_dates[!(other_dates %in% idcols_dates)] - wide2[, other_dates] <- lapply(wide2[, other_dates], function(x) as.Date(strptime(x, format = "%Y%m%d"))) - if ("startDateTime" %in% names(wide2)) { - wide2[, "startDateTime"] <- as.POSIXct(wide2[, "startDateTime"], tz = attr(original_start_dates, "tzone")) - } - if ("endDateTime" %in% names(wide2)) { - wide2[, "endDateTime"] <- as.POSIXct(wide2[, "endDateTime"], tz = attr(original_end_dates, "tzone")) - } - - data <- wide2 - } else { - warning("Reshape can only be used with expanded data. Reshape request will be ignored.") - } - } else { - parameterCd <- unique(data$parm_cd) - } - - if (exists("siteNumbers") && all(!(is.na(siteNumbers))) && length(siteNumbers) > 0) { - siteInfo <- readNWISsite(siteNumbers) - if (nrow(data) > 0) { - siteInfo <- merge( - x = unique(data[, c("agency_cd", "site_no")]), - y = siteInfo, - by = c("agency_cd", "site_no"), - all.x = TRUE - ) - } - attr(data, "siteInfo") <- siteInfo - } - - if (exists("parameterCd") && any(!is.na(parameterCd)) && - length(parameterCd) > 0) { - parameterCd <- parameterCd[!is.na(parameterCd)] - parameterCd <- parameterCd[parameterCd != ""] - varInfo <- readNWISpCode(parameterCd) - attr(data, "variableInfo") <- varInfo - } - - attr(data, "statisticInfo") <- NULL - - attr(data, "url") <- url - attr(data, "comment") <- comment - attr(data, "queryTime") <- queryTime - attr(data, "header") <- header - - return(data) -} diff --git a/R/readWQPdots.R b/R/readWQPdots.R index 03261981..31ec6d78 100644 --- a/R/readWQPdots.R +++ b/R/readWQPdots.R @@ -2,7 +2,7 @@ #' Format and organize WQP arguments that are passed in as \code{...}. #' #' @keywords internal -readWQPdots <- function(..., legacy = FALSE) { +readWQPdots <- function(..., legacy = TRUE) { if (length(list(...)) == 0) { stop("No arguments supplied") diff --git a/R/readWQPqw.R b/R/readWQPqw.R index 0923c0ad..f56df96d 100644 --- a/R/readWQPqw.R +++ b/R/readWQPqw.R @@ -48,7 +48,7 @@ #' } #' @export #' @seealso \code{\link{readWQPdata}}, \code{\link{whatWQPsites}}, -#' \code{\link{readNWISqw}}, and \code{\link{importWQP}} +#' and \code{\link{importWQP}} #' @examplesIf is_dataRetrieval_user() #' \donttest{ #' rawPcode <- readWQPqw("USGS-01594440", "01075", "", "") diff --git a/R/setAccess.R b/R/setAccess.R index bb9df08f..c1ea4bad 100644 --- a/R/setAccess.R +++ b/R/setAccess.R @@ -46,7 +46,6 @@ setAccess <- function(access = "public") { pkg.env$measurements <- "https://waterdata.usgs.gov/nwis/measurements/" pkg.env$peak <- "https://nwis.waterdata.usgs.gov/usa/nwis/peak/" pkg.env$rating <- "https://waterdata.usgs.gov/nwisweb/get_ratings/" - pkg.env$qwdata <- "https://nwis.waterdata.usgs.gov/nwis/qwdata" pkg.env$stat <- "https://waterservices.usgs.gov/nwis/stat/" pkg.env$useNat <- "https://waterdata.usgs.gov/nwis/water_use" pkg.env$pCode <- "https://help.waterdata.usgs.gov/code/parameter_cd_query" diff --git a/R/sysdata.rda b/R/sysdata.rda index 44c350bb..e9befca0 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/_pkgdown.yml b/_pkgdown.yml index b9505f94..96425441 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -68,7 +68,6 @@ reference: - readNWISdv - readNWISuv - readNWISsite - - readNWISqw - readNWISstat - readNWISmeas - readNWISpCode diff --git a/man/constructNWISURL.Rd b/man/constructNWISURL.Rd index 6888b3ce..e00203fe 100644 --- a/man/constructNWISURL.Rd +++ b/man/constructNWISURL.Rd @@ -31,7 +31,7 @@ retrieval for the latest possible record.} \item{service}{string USGS service to call. Possible values are "dv" (daily values), "uv" (unit/instantaneous values), -"qw" (water quality data), "gwlevels" (groundwater),and "rating" (rating curve), +"gwlevels" (groundwater),and "rating" (rating curve), "peak", "meas" (discrete streamflow measurements), "stat" (statistics web service BETA).} @@ -70,12 +70,7 @@ full list of codes.} url string } \description{ -Imports data from NWIS web service. This function gets the data from here: -\url{https://nwis.waterdata.usgs.gov/nwis/qwdata} -A list of parameter codes can be found here: -\url{https://nwis.waterdata.usgs.gov/nwis/pmcodes/} -A list of statistic codes can be found here: -\url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table} +Imports data from NWIS web service. } \examples{ site_id <- "01594440" diff --git a/man/constructWQPURL.Rd b/man/constructWQPURL.Rd index e43858f0..ac7a25e9 100644 --- a/man/constructWQPURL.Rd +++ b/man/constructWQPURL.Rd @@ -4,7 +4,7 @@ \alias{constructWQPURL} \title{Construct WQP url for data retrieval} \usage{ -constructWQPURL(siteNumbers, parameterCd, startDate, endDate, legacy = FALSE) +constructWQPURL(siteNumbers, parameterCd, startDate, endDate, legacy = TRUE) } \arguments{ \item{siteNumbers}{string or vector of strings USGS site number.} diff --git a/man/importRDB1.Rd b/man/importRDB1.Rd index 40c460f2..080a330f 100644 --- a/man/importRDB1.Rd +++ b/man/importRDB1.Rd @@ -88,14 +88,6 @@ unitDataURL <- constructNWISURL(site_id, property, unitData <- importRDB1(unitDataURL, asDateTime = TRUE) -qwURL <- constructNWISURL(c("04024430", "04024000"), - c("34247", "30234", "32104", "34220"), - "2010-11-03", "", "qw", - format = "rdb" -) - -qwData <- importRDB1(qwURL, asDateTime = TRUE, tz = "America/Chicago") - iceSite <- "04024000" start <- "2015-11-09" end <- "2015-11-24" diff --git a/man/parameterCdFile.Rd b/man/parameterCdFile.Rd index 4177b258..99d82bcc 100644 --- a/man/parameterCdFile.Rd +++ b/man/parameterCdFile.Rd @@ -18,7 +18,7 @@ parameter_units \tab character \tab Parameter units\cr } } \description{ -Complete list of USGS parameter codes as of Dec. 20, 2021. +Complete list of USGS parameter codes as of Oct. 24, 2024. } \examples{ head(parameterCdFile[, 1:2]) diff --git a/man/readNGWMNdata.Rd b/man/readNGWMNdata.Rd index c69bd4d8..44c91c5e 100644 --- a/man/readNGWMNdata.Rd +++ b/man/readNGWMNdata.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/readNGWMNdata.R \name{readNGWMNdata} \alias{readNGWMNdata} -\title{Import data from the National Groundwater Monitoring Network \url{https://cida.usgs.gov/ngwmn/}.} +\title{Import data from the National Groundwater Monitoring Network.} \usage{ readNGWMNdata(service, ..., asDateTime = TRUE, tz = "UTC") } diff --git a/man/readNGWMNlevels.Rd b/man/readNGWMNlevels.Rd index 838ac1f1..7a65a9b3 100644 --- a/man/readNGWMNlevels.Rd +++ b/man/readNGWMNlevels.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/readNGWMNdata.R \name{readNGWMNlevels} \alias{readNGWMNlevels} -\title{Retrieve groundwater levels from the National Ground Water Monitoring Network \url{https://cida.usgs.gov/ngwmn/}.} +\title{Retrieve groundwater levels from the National Ground Water Monitoring Network.} \usage{ readNGWMNlevels(siteNumbers, asDateTime = TRUE, tz = "UTC") } @@ -22,7 +22,7 @@ Possible values to provide are "America/New_York", "America/Chicago", "America/D for more information on time zones.} } \description{ -Retrieve groundwater levels from the National Ground Water Monitoring Network \url{https://cida.usgs.gov/ngwmn/}. +Retrieve groundwater levels from the National Ground Water Monitoring Network. } \examples{ \dontshow{if (is_dataRetrieval_user()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/man/readNGWMNsites.Rd b/man/readNGWMNsites.Rd index e1a103dc..d6c13859 100644 --- a/man/readNGWMNsites.Rd +++ b/man/readNGWMNsites.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/readNGWMNdata.R \name{readNGWMNsites} \alias{readNGWMNsites} -\title{Retrieve site data from the National Ground Water Monitoring Network \url{https://cida.usgs.gov/ngwmn/}.} +\title{Retrieve site data from the National Ground Water Monitoring Network.} \usage{ readNGWMNsites(siteNumbers) } @@ -20,7 +20,7 @@ dec_lat_va, dec_lon_va \tab numeric \tab Site latitude and longitude \cr } } \description{ -Retrieve site data from the National Ground Water Monitoring Network \url{https://cida.usgs.gov/ngwmn/}. +Retrieve site data from the National Ground Water Monitoring Network. } \examples{ \dontshow{if (is_dataRetrieval_user()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/man/readNWISqw.Rd b/man/readNWISqw.Rd deleted file mode 100644 index 510c8f34..00000000 --- a/man/readNWISqw.Rd +++ /dev/null @@ -1,79 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readNWISqw.R -\name{readNWISqw} -\alias{readNWISqw} -\title{Raw Data Import for USGS NWIS QW Data} -\usage{ -readNWISqw( - siteNumbers, - parameterCd, - startDate = "", - endDate = "", - expanded = TRUE, - reshape = FALSE, - tz = "UTC" -) -} -\arguments{ -\item{siteNumbers}{character of USGS site numbers. This is usually an 8 digit number} - -\item{parameterCd}{character that contains the code for a parameter -group, or a character vector of 5-digit parameter codes. See \bold{Details}.} - -\item{startDate}{character starting date for data retrieval in the form YYYY-MM-DD. -Default is "" which indicates -retrieval for the earliest possible record. Date arguments are always specified in local time.} - -\item{endDate}{character ending date for data retrieval in the form YYYY-MM-DD. -Default is "" which indicates -retrieval for the latest possible record. Date arguments are always specified in local time.} - -\item{expanded}{logical defaults to \code{TRUE}. If \code{TRUE}, retrieves -additional information. Expanded data includes -remark_cd (remark code), result_va (result value), val_qual_tx -(result value qualifier code), meth_cd (method code), -dqi_cd (data-quality indicator code), rpt_lev_va (reporting level), and -rpt_lev_cd (reporting level type). If \code{FALSE}, -only returns remark_cd (remark code) and result_va (result value). -Expanded = \code{FALSE} will not give -sufficient information for unbiased statistical analysis.} - -\item{reshape}{logical, reshape the expanded data. If \code{TRUE}, then return -a wide data frame with all water-quality in a single row for each sample. -If \code{FALSE} (default), then return a long data frame with each water-quality result in a single row. This -argument is only applicable to expanded data. Data requested using \code{expanded=FALSE} -is always returned in the wide format.} - -\item{tz}{character to set timezone attribute of dateTime. Default is "UTC", and converts the -date times to UTC, properly accounting for daylight savings times based on the -data's provided tz_cd column. -Possible values to provide are "America/New_York", "America/Chicago", -"America/Denver", "America/Los_Angeles", "America/Anchorage", as well as the -following which do not use daylight savings time: "America/Honolulu", -"America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". -See also \code{OlsonNames()} -for more information on time zones.} -} -\value{ -A data frame not including USGS data newer than March 11, 2024. -} -\description{ -Deprecated function. USGS NWIS QW services will be discontinued, when that happens -this function will be removed from dataRetrieval. Please use\code{\link{readWQPqw}} or -\code{\link{readWQPdata}} instead. -} -\details{ -As of March 11, 2024, NWIS discrete water quality services are "frozen": -any public data retrieval will not include any new data. - -Contact CompTools@usgs.gov with additional questions! -} -\seealso{ -\code{\link{readWQPdata}}, \code{\link{whatWQPsites}}, -\code{\link{readWQPqw}}, \code{\link{constructNWISURL}} -} -\keyword{USGS} -\keyword{data} -\keyword{import} -\keyword{service} -\keyword{web} diff --git a/man/readWQPdots.Rd b/man/readWQPdots.Rd index ca3ac553..a3b7fb96 100644 --- a/man/readWQPdots.Rd +++ b/man/readWQPdots.Rd @@ -4,7 +4,7 @@ \alias{readWQPdots} \title{Format and organize WQP arguments that are passed in as \code{...}.} \usage{ -readWQPdots(..., legacy = FALSE) +readWQPdots(..., legacy = TRUE) } \description{ Format and organize WQP arguments that are passed in as \code{...}. diff --git a/man/readWQPqw.Rd b/man/readWQPqw.Rd index ea5e41a0..b0f4c72f 100644 --- a/man/readWQPqw.Rd +++ b/man/readWQPqw.Rd @@ -93,7 +93,7 @@ SC <- readWQPqw(siteNumbers = "USGS-05288705", parameterCd = "00300", convertTyp } \seealso{ \code{\link{readWQPdata}}, \code{\link{whatWQPsites}}, -\code{\link{readNWISqw}}, and \code{\link{importWQP}} +and \code{\link{importWQP}} } \keyword{USGS} \keyword{data} diff --git a/tests/testthat/tests_general.R b/tests/testthat/tests_general.R index 85cc180d..ef2af407 100644 --- a/tests/testthat/tests_general.R +++ b/tests/testthat/tests_general.R @@ -231,57 +231,57 @@ test_that("whatNWISdata", { test_that("General WQP retrievals working", { testthat::skip_on_cran() nameToUse <- "pH" - pHData <- readWQPdata(siteid = "USGS-04024315", - characteristicName = nameToUse, - service = "ResultWQX3") - expect_is(pHData$Activity_StartDateTime, "POSIXct") - - # testing lists: - startDate <- as.Date("2022-01-01") - secchi.names <- c("Depth, Secchi disk depth", - "Secchi depth", - "Water transparency, Secchi disc", - "Depth, Secchi disk depth (choice list)") - # "Transparency, Secchi tube with disk", - # "Secchi Reading Condition (choice list)", - # "Depth, Secchi disk visible at bottom (Y/N) (choice list)") - - args_2 <- list( - "startDateLo" = startDate, - "startDateHi" = "2024-01-01", - statecode = "WI", - characteristicName = secchi.names - ) - - # Testing multiple lists: - arg_3 <- list( - "startDateLo" = startDate, - "startDateHi" = "2023-12-31" - ) - arg_4 <- list( - statecode = "WI", - characteristicName = secchi.names - ) - - lakeData <- readWQPdata(args_2, ignore_attributes = TRUE) - expect_true(nrow(lakeData) > 0) - lakeSites <- whatWQPsites(args_2) - expect_type(lakeSites, "list") - - wqp.summary_no_atts <- readWQPdata( - siteid = "USGS-04024315", - characteristicName = nameToUse, - ignore_attributes = TRUE, - service = "ResultWQX3" - ) - expect_true(!all(c("siteInfo", "variableInfo") %in% names(attributes(wqp.summary_no_atts)))) - - rawPcode <- readWQPqw("USGS-01594440", "01075", "", "", legacy = FALSE) - expect_true(all(c("url", "queryTime", "siteInfo", "headerInfo") %in% - names(attributes(rawPcode)))) - - # This means wqp_check_status was called: - expect_true("dataProviders" %in% names(attr(rawPcode, "headerInfo"))) + # pHData <- readWQPdata(siteid = "USGS-04024315", + # characteristicName = nameToUse, + # service = "ResultWQX3") + # expect_is(pHData$Activity_StartDateTime, "POSIXct") + # + # # testing lists: + # startDate <- as.Date("2022-01-01") + # secchi.names <- c("Depth, Secchi disk depth", + # "Secchi depth", + # "Water transparency, Secchi disc", + # "Depth, Secchi disk depth (choice list)") + # # "Transparency, Secchi tube with disk", + # # "Secchi Reading Condition (choice list)", + # # "Depth, Secchi disk visible at bottom (Y/N) (choice list)") + # + # args_2 <- list( + # "startDateLo" = startDate, + # "startDateHi" = "2024-01-01", + # statecode = "WI", + # characteristicName = secchi.names + # ) + # + # # Testing multiple lists: + # arg_3 <- list( + # "startDateLo" = startDate, + # "startDateHi" = "2023-12-31" + # ) + # arg_4 <- list( + # statecode = "WI", + # characteristicName = secchi.names + # ) + # + # lakeData <- readWQPdata(args_2, ignore_attributes = TRUE) + # expect_true(nrow(lakeData) > 0) + # lakeSites <- whatWQPsites(args_2) + # expect_type(lakeSites, "list") + # + # wqp.summary_no_atts <- readWQPdata( + # siteid = "USGS-04024315", + # characteristicName = nameToUse, + # ignore_attributes = TRUE, + # service = "ResultWQX3" + # ) + # expect_true(!all(c("siteInfo", "variableInfo") %in% names(attributes(wqp.summary_no_atts)))) + # + # rawPcode <- readWQPqw("USGS-01594440", "01075", "", "", legacy = FALSE) + # expect_true(all(c("url", "queryTime", "siteInfo", "headerInfo") %in% + # names(attributes(rawPcode)))) + # + # # This means wqp_check_status was called: + # expect_true("dataProviders" %in% names(attr(rawPcode, "headerInfo"))) rawPcode2 <- readWQPqw("USGS-01594440", "01075", "", "", ignore_attributes = TRUE) expect_true(all(!c( "queryTime", "siteInfo") %in% @@ -290,32 +290,32 @@ test_that("General WQP retrievals working", { # This means wqp_check_status wasn't called: expect_false("dataProviders" %in% names(attr(rawPcode2, "headerInfo"))) - pHData <- readWQPdata(siteid = "USGS-04024315", - characteristicName = "pH", - service = "ResultWQX3") - expect_true(all(c("url", "queryTime", "siteInfo", "headerInfo") %in% - names(attributes(pHData)))) - - # This means wqp_check_status was called: - expect_true("dataProviders" %in% names(attr(pHData, "headerInfo"))) - - pHData2 <- readWQPdata(siteid = "USGS-04024315", - characteristicName = "pH", - ignore_attributes = TRUE, - service = "ResultWQX3") - expect_true(all(!c("queryTime", "siteInfo") %in% - names(attributes(pHData2)))) - - # This means wqp_check_status was called: - expect_false("dataProviders" %in% names(attr(pHData2, "headerInfo"))) - - rawPcode <- readWQPqw("USGS-01594440", "01075", - ignore_attributes = TRUE, legacy = FALSE) - headerInfo <- attr(rawPcode, "headerInfo") - wqp_request_id <- headerInfo$`wqp-request-id` - count_info <- wqp_check_status(wqp_request_id) - - expect_true("dataProviders" %in% names(count_info)) + # pHData <- readWQPdata(siteid = "USGS-04024315", + # characteristicName = "pH", + # service = "ResultWQX3") + # expect_true(all(c("url", "queryTime", "siteInfo", "headerInfo") %in% + # names(attributes(pHData)))) + # + # # This means wqp_check_status was called: + # expect_true("dataProviders" %in% names(attr(pHData, "headerInfo"))) + # + # pHData2 <- readWQPdata(siteid = "USGS-04024315", + # characteristicName = "pH", + # ignore_attributes = TRUE, + # service = "ResultWQX3") + # expect_true(all(!c("queryTime", "siteInfo") %in% + # names(attributes(pHData2)))) + # + # # This means wqp_check_status was called: + # expect_false("dataProviders" %in% names(attr(pHData2, "headerInfo"))) + # + # rawPcode <- readWQPqw("USGS-01594440", "01075", + # ignore_attributes = TRUE, legacy = FALSE) + # headerInfo <- attr(rawPcode, "headerInfo") + # wqp_request_id <- headerInfo$`wqp-request-id` + # count_info <- wqp_check_status(wqp_request_id) + # + # expect_true("dataProviders" %in% names(count_info)) }) @@ -557,16 +557,16 @@ test_that("profiles", { ) %in% names(proj_mlwd))) # Data profiles: "narrow": - samp_data <- readWQPdata( - siteid = "USGS-04024315", - service = "ResultWQX3", - dataProfile = "narrow" - ) - - expect_true(all(c( - "Activity_StartDateTime", - "LastChangeDate" - ) %in% names(samp_data))) + # samp_data <- readWQPdata( + # siteid = "USGS-04024315", + # service = "ResultWQX3", + # dataProfile = "narrow" + # ) + # + # expect_true(all(c( + # "Activity_StartDateTime", + # "LastChangeDate" + # ) %in% names(samp_data))) # Data profiles: "Sample Results (biological metadata)" samp_bio <- readWQPdata( @@ -689,10 +689,10 @@ test_that("readWQPsummary", { test_that("importWQP convertType", { testthat::skip_on_cran() - rawSampleURL_NoZip <- constructWQPURL("USGS-01594440", "01075", "", "") - rawSampleURL_NoZip_char <- importWQP(rawSampleURL_NoZip, convertType = FALSE) - expect_is(rawSampleURL_NoZip_char$Result_Measure, "character") - + # rawSampleURL_NoZip <- constructWQPURL("USGS-01594440", "01075", "", "") + # rawSampleURL_NoZip_char <- importWQP(rawSampleURL_NoZip, convertType = FALSE) + # expect_is(rawSampleURL_NoZip_char$Result_Measure, "character") + # # Put back in when services get more robust. # phos <- readWQPdata(statecode = "WI", countycode = "Dane", # characteristicName = "Phosphorus", diff --git a/tests/testthat/tests_imports.R b/tests/testthat/tests_imports.R index 89d26949..652c0e2f 100644 --- a/tests/testthat/tests_imports.R +++ b/tests/testthat/tests_imports.R @@ -34,17 +34,6 @@ test_that("External importRDB1 tests", { # expect_that(as.numeric(unitData[which(unitData$tz_cd == "EST")[1],"datetime"]), # equals(as.numeric(as.POSIXct("2013-11-03 01:00:00", tz="UTC")+60*60*5))) - - qwURL <- constructNWISURL(c("04024430", "04024000"), - c("34247", "30234", "32104", "34220"), - "2010-11-03", "", "qw", - format = "rdb" - ) - qwData <- importRDB1(qwURL, tz = "America/Chicago") - expect_is(qwData$sample_dt, "Date") - expect_is(qwData$startDateTime, "POSIXct") - - site <- "05427850" url <- constructNWISURL(site, "00060", "2015-01-01", "", "dv", @@ -242,14 +231,14 @@ test_that("External WQP tests", { testthat::skip_on_cran() rawSampleURL <- constructWQPURL("USGS-01594440", "01075", "", "", legacy = FALSE) - rawSample <- importWQP(rawSampleURL) - expect_is(rawSample$Activity_StartDateTime, "POSIXct") + # rawSample <- importWQP(rawSampleURL) + # expect_is(rawSample$Activity_StartDateTime, "POSIXct") url2 <- constructWQPURL("USGS-01594440", "01075", "", "", legacy = TRUE) rawSample2 <- suppressWarnings(importWQP(url2)) expect_is(rawSample2$ActivityStartDateTime, "POSIXct") STORETex <- constructWQPURL("WIDNR_WQX-10032762", "Specific conductance", "", "", legacy = FALSE) - STORETdata <- importWQP(STORETex) - expect_is(STORETdata$Activity_StartDateTime, "POSIXct") + # STORETdata <- importWQP(STORETex) + # expect_is(STORETdata$Activity_StartDateTime, "POSIXct") }) diff --git a/tests/testthat/tests_userFriendly_fxns.R b/tests/testthat/tests_userFriendly_fxns.R index 991216a4..328fdb98 100644 --- a/tests/testthat/tests_userFriendly_fxns.R +++ b/tests/testthat/tests_userFriendly_fxns.R @@ -352,6 +352,7 @@ test_that("Construct NWIS urls", { startDate, endDate, "dv", statCd = c("00003", "00001") ) + # nolint start: line_length_linter expect_equal(url_daily, "https://waterservices.usgs.gov/nwis/dv/?site=01594440&format=waterml,1.1&ParameterCd=00060,00010&StatCd=00003,00001&startDT=1985-01-01") @@ -361,55 +362,11 @@ test_that("Construct NWIS urls", { "https://nwis.waterservices.usgs.gov/nwis/iv/?site=01594440&format=waterml,1.1&ParameterCd=00060,00010&startDT=2012-06-28&endDT=2012-06-30" ) - url_qw_single <- constructNWISURL(siteNumber, "01075", startDate, endDate, "qw") - expect_equal(url_qw_single, "https://nwis.waterdata.usgs.gov/nwis/qwdata?search_site_no=01594440&search_site_no_match_type=exact&multiple_parameter_cds=01075¶m_cd_operator=AND&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0&begin_date=1985-01-01") - - url_qw <- constructNWISURL( - siteNumber, c("01075", "00029", "00453"), - startDate, endDate, "qw" - ) - expect_equal(url_qw, "https://nwis.waterdata.usgs.gov/nwis/qwdata?search_site_no=01594440&search_site_no_match_type=exact&multiple_parameter_cds=01075,00029,00453¶m_cd_operator=OR&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0&begin_date=1985-01-01") - url_daily_tsv <- constructNWISURL(siteNumber, pCode, startDate, endDate, "dv", statCd = c("00003", "00001"), format = "tsv" ) expect_equal(url_daily_tsv, "https://waterservices.usgs.gov/nwis/dv/?site=01594440&format=rdb,1.0&ParameterCd=00060,00010&StatCd=00003,00001&startDT=1985-01-01") - setAccess("internal") - url_rating <- constructNWISURL(siteNumber, service = "rating", ratingType = "base") - expect_equal(url_rating, "https://waterdata.usgs.gov/nwisweb/get_ratings/?Access=3&site_no=01594440&file_type=base") - url_peak <- constructNWISURL(siteNumber, service = "peak") - expect_equal(url_peak, "https://nwis.waterdata.usgs.gov/usa/nwis/peak/?Access=3&site_no=01594440&range_selection=date_range&format=rdb") - - url_meas <- constructNWISURL(siteNumber, service = "meas") - expect_equal(url_meas, "https://waterdata.usgs.gov/nwis/measurements/?Access=3&site_no=01594440&range_selection=date_range&format=rdb_expanded") - - urlQW <- constructNWISURL("450456092225801", "70300", - startDate = "", endDate = "", - "qw", expanded = TRUE - ) - expect_equal(urlQW, "https://nwis.waterdata.usgs.gov/nwis/qwdata?Access=3&search_site_no=450456092225801&search_site_no_match_type=exact&multiple_parameter_cds=70300¶m_cd_operator=AND&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0") - - setAccess("cooperator") - urlQW <- constructNWISURL("450456092225801", "70300", - startDate = "", endDate = "", "qw", expanded = TRUE - ) - expect_equal(urlQW, "https://nwis.waterdata.usgs.gov/nwis/qwdata?Access=1&search_site_no=450456092225801&search_site_no_match_type=exact&multiple_parameter_cds=70300¶m_cd_operator=AND&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0") - - setAccess("USGS") - urlQW <- constructNWISURL("450456092225801", "70300", - startDate = "", - endDate = "", "qw", expanded = TRUE - ) - expect_equal(urlQW, "https://nwis.waterdata.usgs.gov/nwis/qwdata?Access=2&search_site_no=450456092225801&search_site_no_match_type=exact&multiple_parameter_cds=70300¶m_cd_operator=AND&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0") - - setAccess("public") - urlQW <- constructNWISURL("450456092225801", "70300", - startDate = "", - endDate = "", "qw", expanded = TRUE - ) - expect_equal(urlQW, "https://nwis.waterdata.usgs.gov/nwis/qwdata?search_site_no=450456092225801&search_site_no_match_type=exact&multiple_parameter_cds=70300¶m_cd_operator=AND&list_of_search_criteria=search_site_no,multiple_parameter_cds&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&inventory_output=0&rdb_inventory_output=file&TZoutput=0&pm_cd_compare=Greater%20than&radio_parm_cds=previous_parm_cds&qw_attributes=0&format=rdb&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&qw_sample_wide=0") - url_use <- constructUseURL( years = c(1990, 1995), stateCd = "Ohio", @@ -428,11 +385,11 @@ test_that("Construct WQP urls", { startDate <- "1985-01-01" endDate <- "" pCode <- c("00060", "00010") + url_wqp <- constructWQPURL( paste("USGS", site_id, sep = "-"), c("01075", "00029", "00453"), - startDate, endDate - ) + startDate, endDate, legacy = FALSE) # nolint start: line_length_linter expect_equal( url_wqp, @@ -444,11 +401,12 @@ test_that("Construct WQP urls", { "Temperature", "Temperature, sample", "Temperature, water", "Temperature, water, deg F" ) + obs_url_orig <- constructWQPURL( siteNumbers = c("IIDFG-41WSSPAHS", "USGS-02352560"), - parameterCd = c("Temperature", "Temperature, sample", "Temperature, water", "Temperature, water, deg F"), - "", "" - ) + parameterCd = charNames, + startDate = "", endDate = "", legacy = FALSE) + expect_equal( obs_url_orig, "https://www.waterqualitydata.us/wqx3/Result/search?siteid=IIDFG-41WSSPAHS&siteid=USGS-02352560&characteristicName=Temperature&characteristicName=Temperature%2C%20sample&characteristicName=Temperature%2C%20water&characteristicName=Temperature%2C%20water%2C%20deg%20F&mimeType=csv&dataProfile=basicPhysChem" @@ -466,8 +424,8 @@ test_that("Construct WQP urls", { url_wqp <- constructWQPURL( paste("USGS", siteNumber, sep = "-"), c("01075", "00029", "00453"), - startDate, endDate - ) + startDate, endDate,legacy = FALSE) + # nolint start: line_length_linter expect_equal( url_wqp, @@ -497,7 +455,7 @@ test_that("pCode Stuff", { expect_equal(paramINFO$parameter_group_nm[3:4], c(NA_character_, NA_character_)) paramINFO <- readNWISpCode("all") - expect_true(nrow(paramINFO) > 24000) + expect_true(nrow(paramINFO) > 20000) expect_equal( attr(paramINFO, "url"), "https://help.waterdata.usgs.gov/code/parameter_cd_query?fmt=rdb&group_cd=%" diff --git a/vignettes/Status.Rmd b/vignettes/Status.Rmd index 0ccfb99a..e3c5ee98 100644 --- a/vignettes/Status.Rmd +++ b/vignettes/Status.Rmd @@ -21,12 +21,7 @@ Contact CompTools@usgs.gov with additional questions! # Overview -As of March 11, 2024, NWIS **discrete water quality** services are "frozen": any public data retrieval will not include any new data. - -### NWIS qw services - -Discrete water quality samples data are undergoing modernization, and NWIS services pulling that discrete water quality data ('qw') are no longer being updated as of March 11, 2024. A full decommission is expected approximately 6 months later. Learn more about the upcoming change and where to find the new samples data in our [blog](https://waterdata.usgs.gov/blog/changes-to-sample-data/). - +As of March 11, 2024, NWIS **discrete water quality** services are "frozen": any public data retrieval will not include any new data. Learn more about the upcoming change and where to find the new samples data in our [blog](https://waterdata.usgs.gov/blog/changes-to-sample-data/). If you have additional questions about the NWIS qw data service, email CompTools@usgs.gov. @@ -62,11 +57,11 @@ df <- data.frame(Function = c("readWQPdata", "readNWISqw", "readWQPsummary", "whatNWISdata"), - Status = c("Set to WQX3 full profile by default. 'legacy' option exists.", - "Set to WQX3 narrow profile by default. 'legacy' option exists.", - "Set to WQX3 station profile by default. 'legacy' option exists.", + Status = c("Set to legacy options by default. WQX3 options available.", + "Set to legacy options by default. WQX3 options available.", + "Set to legacy options by default. WQX3 options available.", rep("Currently only available via legacy services.", 3), - "Deprecated: should not be continued to use.", + "Retired.", "Does not have accurate information for USGS data.", "Does not have accurate information for qw data.")) @@ -85,7 +80,8 @@ An example of a WQX 3.0 return: ```{r} library(dataRetrieval) rawPcode <- readWQPqw(siteNumbers = "USGS-01594440", - parameterCd = "01075") + parameterCd = "01075", + legacy = FALSE) attr(rawPcode, "url") ``` @@ -105,7 +101,7 @@ The "readWQPdata" function is the most flexible function to get WQP data. Curren ### WQX 3.0 -There are now 2 "services" available: StationWQX and ResultWQX. The "ResultWQX" service has multiple available "dataProfiles". +There are now 3 "services" available: ResultWQX, StationWQX and ActivityWQX. The "ResultWQX" service has multiple available "dataProfiles". | Service | dataProfile | | -------------- | ---------- | @@ -113,6 +109,7 @@ There are now 2 "services" available: StationWQX and ResultWQX. The "ResultWQX" | ResultWQX | fullPhysChem | | ResultWQX | basicPhysChem | | ResultWQX | narrow | +| ActivityWQX | | Examples: @@ -148,7 +145,7 @@ attr(data_sites, "url") ### WQX 2.0 - Legacy -There are 8 services available from the legacy WQP. The Station and Result legacy services can still be accessed, but users should move to StationWQX and ResultWQX. As other former services become available in WQX 3.0, we will update these documents. +There are 8 services available from the legacy WQP. The Station and Result legacy services can still be accessed, but users should move to StationWQX, ResultWQX, and ActivityWQX. As other former services become available in WQX 3.0, we will update these documents. | Service | dataProfile | WQX 3.0 option? | | -------------- | ---------- | ---------- | @@ -156,7 +153,7 @@ There are 8 services available from the legacy WQP. The Station and Result legac | Result | resultPhysChem | ResultWQX | | Result | biological | | Result | narrowResult | ResultWQX | -| Activity | activityAll | | +| Activity | activityAll | ActivityWQX | | ActivityMetric | | | | Project | | | | ProjectMonitoringLocationWeighting | | | @@ -253,8 +250,6 @@ So for site "05114000", there are 381 NWIS qw parameters that have been measured New services/functions are being developed to replace the lost functionality so check back here for updated information. - - # Known Dependencies ### EGRET diff --git a/vignettes/qwdata_changes.Rmd b/vignettes/qwdata_changes.Rmd index 1fb971ac..ec8bffc4 100644 --- a/vignettes/qwdata_changes.Rmd +++ b/vignettes/qwdata_changes.Rmd @@ -55,23 +55,9 @@ This is available as of `dataRetrieval` version 2.7.16. Starting with 2.7.16, al ## `readNWISqw` -Users will notice a Warning message when using this function: +This function was retired as of Oct. 24, 2024. -```{r eval=FALSE} -site_ids <- c("04024430", "04024000") -parameterCd <- c("34247", "30234", "32104", "34220") -nwisData <- readNWISqw(site_ids, parameterCd) -``` - -``` -Warning message: -In readNWISqw(site_ids, parameterCd) : WARNING: NWIS does not deliver discrete water quality data newer than March 11, 2024 for updates to existing data. For additional details, see: -https://doi-usgs.github.io/dataRetrieval/articles/Status.html -``` - -Please don't ignore this warning, the function will eventually be *removed* from the `dataRetrieval` package. - -So...what do you do instead? The function you will need to move to is `readWQPqw`. First, you'll need to convert the numeric USGS site ID's into something that the Water Quality Portal will accept, which requires the agency prefix. For most USGS sites this will mean pasting 'USGS-' before the site number, although it is important to note that there are some USGS sites that begin with a different prefix: it is up to users to determine the agency code.. +So...what do you use instead? The function you will need to move to is `readWQPqw`. First, you'll need to convert the numeric USGS site ID's into something that the Water Quality Portal will accept, which requires the agency prefix. For most USGS sites this will mean pasting 'USGS-' before the site number, although it is important to note that there are some USGS sites that begin with a different prefix: it is up to users to determine the agency code.. Here's an example: @@ -79,12 +65,13 @@ Here's an example: wqpData <- readWQPqw(paste0("USGS-", site_ids), parameterCd) ``` +Let's say we have a data frame that we got from the retired `readNWISqw` function and we saved it as `nwisData`. ```{r echo=FALSE} nwisData <- readRDS("nwisData.rds") wqpData <- readRDS("wqpData.rds") ``` -Let's compare the number of rows, number of columns, and attributes to each return: +First we compare the number of rows, number of columns, and attributes to each return: ```{r} diff --git a/vignettes/wqx3_development_plan.Rmd b/vignettes/wqx3_development_plan.Rmd index c732044d..0c97dba1 100644 --- a/vignettes/wqx3_development_plan.Rmd +++ b/vignettes/wqx3_development_plan.Rmd @@ -53,7 +53,7 @@ And just a quick reminder that we now offer a suite of data retrieval software t ## Why are updates happening? Part I -The changes result from a couple of relatively major updates to how both the USGS and the WQP deliver discrete water quality and sample data. Discrete data from USGS are now being delivered in the Water Quality Exchange (or WQX) format. Previously, these data were available using a set of NWIS functions, e.g. `readNWISqw()`. The NWIS data format was specific to USGS data and relied on codes for describing the metadata. Now, USGS data will be formatted in the same way as the data published by other providers on the Water Quality Portal. This change will make it easier for users to combine USGS data with data from these other sources. +The changes result from a couple of relatively major updates to how both the USGS and the WQP deliver discrete water quality and sample data. Discrete data from USGS are now being delivered in the Water Quality Exchange (or WQX) format. Previously, these data were available using a set of NWIS functions, e.g. `readNWISqw()` (now retired). The NWIS data format was specific to USGS data and relied on codes for describing the metadata. Now, USGS data will be formatted in the same way as the data published by other providers on the Water Quality Portal. This change will make it easier for users to combine USGS data with data from these other sources. How will this impact data delivery? For `dataRetrieval`, this means that there is a new USGS web service that is available for us to build new functionality. However, there are changes that will require some adjustment. Some of the existing USGS NWIS services that we’ve relied on for years are reaching their end of life and will soon become deprecated. The services for pulling discrete WQ data still work, however they are delivering STALE data. As of March 11, 2024, all queries to the legacy NWIS qw data sources will pull the same data regardless of whether there are new data, and no changes to the data delivered from these functions is going to happen moving forward.