Skip to content

Commit

Permalink
Merge pull request #734 from ldecicco-USGS/main
Browse files Browse the repository at this point in the history
Remove readNWISqw
  • Loading branch information
ldecicco-USGS authored Oct 24, 2024
2 parents 25ec8af + 02f11fb commit 1da6f3c
Show file tree
Hide file tree
Showing 28 changed files with 144 additions and 568 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export(readNWISgwl)
export(readNWISmeas)
export(readNWISpCode)
export(readNWISpeak)
export(readNWISqw)
export(readNWISrating)
export(readNWISsite)
export(readNWISstat)
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
70 changes: 5 additions & 65 deletions R/constructNWISURL.R
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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)
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -354,7 +294,7 @@ constructWQPURL <- function(siteNumbers,
parameterCd,
startDate,
endDate,
legacy = FALSE) {
legacy = TRUE) {

allPCode <- any(toupper(parameterCd) == "ALL")
if(!allPCode){
Expand Down
2 changes: 1 addition & 1 deletion R/dataRetrievals-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions R/importRDB1.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions R/readNGWMNdata.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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}.
Expand Down Expand Up @@ -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}.
Expand Down
191 changes: 0 additions & 191 deletions R/readNWISqw.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/readWQPdots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion R/readWQPqw.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", "", "")
Expand Down
1 change: 0 additions & 1 deletion R/setAccess.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
Loading

0 comments on commit 1da6f3c

Please sign in to comment.