Skip to content
Merged

V1 #926

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ BuildVignettes: true
VignetteBuilder: knitr
BugReports: https://github.com/DOI-USGS/dataRetrieval/issues
Roxygen: list(markdown = TRUE)
Config/roxygen2/version: 8.0.0
Config/roxygen2/version: 8.1.0
20 changes: 11 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ export(whatWQPsamples)
export(whatWQPsites)
export(wqp_check_status)
export(zeroPad)
importFrom(data.table,":=")
importFrom(data.table,.BY)
importFrom(data.table,.EACHI)
importFrom(data.table,.GRP)
importFrom(data.table,.I)
importFrom(data.table,.N)
importFrom(data.table,.NGRP)
importFrom(data.table,.SD)
importFrom(data.table,data.table)
importFrom(data.table,
":=",
.BY,
.EACHI,
.GRP,
.I,
.N,
.NGRP,
.SD,
data.table
)
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
dataRetrieval 2.7.26
===================
* Switching to v1 of the Water Data APIs.
* Added suite of read_ngwmn to access new National Groundwater Monitoring
Network API.
* Created get_monitoring_location_arguments to help users understand
what new optional arguments are available in many of the read_waterdata functions.
* Added ability to use `...` in the Water Data functions for: daily, latest-continuous, field-measurements, latest-daily, latest-field-measurements, continuous, and peaks. The "..." argument can now accept any parameter that is output from the make_monitoring_location_arguments function.
* Added "q" argument to read_waterdata_monitoring_location. Full-text search across the most relevant text fields for this collection (e.g. site name, identifier, number, state, county, and site type).
* Added "skipGeometry" argument to read_waterdata_continuous. Previously geometry wasn't included with continuous data, but now is supported.
* Deprecated `pcode_to_name` since the service was removed.

dataRetrieval 2.7.25
===================
Expand Down
5 changes: 2 additions & 3 deletions R/AAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pkg.env <- new.env()
options(
"dataRetrieval.nldi_base" = "https://api.water.usgs.gov/nldi/linked-data/"
)
options("dataRetrieval.api_version" = "v0")
options("dataRetrieval.api_version" = "v1")
options("dataRetrieval.api_version_stat" = "v0")
options("dataRetrieval.attach_request" = TRUE)
options("dataRetrieval.convertType" = TRUE)
Expand Down Expand Up @@ -138,8 +138,7 @@ https://doi-usgs.github.io/dataRetrieval/articles/Status.html"

new_nwis_message <- function() {
return(
"ALERT: All NWIS services are slated for decommission
and new dataRetrieval functions will be added.
"ALERT: All NWIS services are slated for decommission in early 2027.
For up-to-date information, see:
https://doi-usgs.github.io/dataRetrieval/articles/Status.html"
)
Expand Down
5 changes: 5 additions & 0 deletions R/citations.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
#' print(nwis_citation, style = "citation")
#' }
create_NWIS_bib <- function(x) {
.Deprecated(
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata functions."
)

textVersion <- paste0(
"U.S. Geological Survey, ",
format(attr(x, "queryTime"), "%Y"),
Expand Down
7 changes: 2 additions & 5 deletions R/dataRetrieval-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ NULL

#' Data to convert USGS parameter code to characteristic names
#'
#' Data pulled from Water Quality Portal on December 20, 2021. The data was pulled from
#' <https://www.waterqualitydata.us/Codes/public_srsnames/?mimeType=csv>.
#'
#' @name pCodeToName
#' @return pCodeToName data frame with information about USGS parameters and how they
#' relate to characteristic names (useful for WQP requests).
Expand Down Expand Up @@ -208,14 +205,14 @@ NULL
# "field-measurements", "latest-daily",
# "continuous", "field-measurements-metadata",
# "combined-metadata", "channel-measurements", "peaks")
#
#
# property_list <- list()
# for(service in services){
# property_list[[service]] <- dataRetrieval:::get_properties_for_docs(service)
# }
#
# num_cols <- c("value", "contributing_drainage_area", "drainage_area",
# #"altitude_accuracy",
# #"altitude_accuracy",
# "well_construction_depth",
# "hole_construction_depth", "channel_flow", "channel_width",
# "channel_area", "channel_velocity", "channel_location_distance")
Expand Down
64 changes: 12 additions & 52 deletions R/pcode_to_name.R
Original file line number Diff line number Diff line change
@@ -1,64 +1,24 @@
#' Parameter code to characteristic name
#'
#' This function is useful to fine what characteristic name, result sample
#' fraction, unit code, and other parameters are mapped with USGS parameter
#' codes. This information is useful for converting workflows from a more
#' traditional NWIS water quality retrieval to a Water Quality Portal retrieval.
#' This function no longer works because the underlying service
#' has been removed. Similar functionality can be found with
#' `check_waterdata_sample_params`.
#'
#' @export
#' @param parameterCd character that contains the code for a character vector
#' of 5-digit parameter codes. Default is "all" which will return a complete
#' list of parameter codes that have been mapped to a characteristic name.
#' @return a data frame with columns "parm_cd", "description",
#' "characteristicname", "measureunitcode", "resultsamplefraction",
#' "resulttemperaturebasis", "resultstatisticalbasis", "resulttimebasis",
#' "resultweightbasis", "resultparticlesizebasis", "last_rev_dt"
#' of 5-digit parameter codes.
#' @examples
#' pcodes <- c("00070", "00075", "00430", "52642")
#' \donttest{
#'
#' all <- pcode_to_name()
#' some <- pcode_to_name(pcodes)
#' all_new <- read_waterdata_parameter_codes(parameter_code = pcodes)
#' ref_list <- check_waterdata_sample_params("reference-list")
#' ref_list_sm <- ref_list[ref_list$parm_cd %in% pcodes, ]
#'
#' }
pcode_to_name <- function(parameterCd = "all") {
parameterCd.orig <- parameterCd
parameterCd <- parameterCd[!is.na(parameterCd)]

url_all <- "https://www.waterqualitydata.us/Codes/public_srsnames/?mimeType=json"
doc <- get_nldi_sources(url_all)
retval <- doc[["pcodes"]]

if (all(tolower(parameterCd) != "all")) {
retval <- retval[retval$parm_cd %in% parameterCd, ]
}

attr(retval, "url") <- url_all

if (any(parameterCd != "all")) {
if (nrow(retval) != length(unique(parameterCd))) {
badPcode <- parameterCd[!(parameterCd %in% retval$parm_cd)]
warning(
"The following pCodes seem mistyped, and no information was returned: ",
paste(badPcode, collapse = ", ")
)
}
}

if (nrow(retval) != sum(is.na(parameterCd.orig))) {
na.params <- data.frame(matrix(
ncol = ncol(retval),
nrow = sum(is.na(parameterCd.orig))
))
names(na.params) <- names(retval)
retval <- rbind(retval, na.params)
}

# order by parameterCd.orig
if (!isTRUE(parameterCd.orig == "all")) {
retval <- retval[match(parameterCd.orig, retval$parm_cd), ]
retval$parm_cd <- parameterCd.orig
}

return(retval)
.Deprecated(
new = "check_waterdata_sample_params",
package = "dataRetrieval",
msg = "Convert to check_waterdata_sample_params('reference-list')."
)
}
3 changes: 1 addition & 2 deletions R/readWQPdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
#' Sampling Activity \tab ActivityWQX3 \tab /wqx3/Activity/search \cr
#' }
#'
#' @param \dots see <https://www.waterqualitydata.us/webservices_documentation> for a complete list of options.
#' A list of arguments can also be supplied. For more information see the above
#' @param \dots A list of arguments can also be supplied. For more information see the above
#' description for this help file. One way to figure out how to construct a WQP query is to go to the "Advanced"
#' form in the Water Quality Portal. Use the form to discover what parameters are available. Once the query is
#' set in the form, scroll down to the "Query URL". You will see the parameters
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_field_measurements.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#' @examplesIf is_dataRetrieval_user()
#'
#' \donttest{
#' site <- "USGS-02238500"
#' site <- "USGS-14202650"
#' field_data_sf <- read_waterdata_field_measurements(monitoring_location_id = site)
#'
#' groundwater <- read_waterdata_field_measurements(monitoring_location_id = "USGS-375907091432201")
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_monitoring_location.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ read_waterdata_monitoring_location <- function(
bbox = NA,
skipGeometry = NA,
...,
convertType = getOption("dataRetrieval.convertType"),
limit = getOption("dataRetrieval.limit"),
no_paging = getOption("dataRetrieval.no_paging"),
chunk_size = getOption("dataRetrieval.site_chunk_size_meta"),
Expand All @@ -159,7 +160,6 @@ read_waterdata_monitoring_location <- function(
rlang::check_dots_empty()

args <- mget(names(formals()))
args[["convertType"]] <- FALSE

return_list <- get_ogc_data(args, output_id, service)

Expand Down
56 changes: 46 additions & 10 deletions R/read_waterdata_ts_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
#' @param last_modified `r get_ogc_params("time-series-metadata")$last_modified`
#'
#' See also Details below for more information.
#' @param begin_utc `r get_ogc_params("time-series-metadata")$begin_utc`
#' #'
#' See also Details below for more information.
#' @param end_utc `r get_ogc_params("time-series-metadata")$end_utc`
#'
#' See also Details below for more information.
#' @param hydrologic_unit_code `r get_ogc_params("time-series-metadata")$hydrologic_unit_code`
#' @param state_name `r get_ogc_params("time-series-metadata")$state_name`
#' @param thresholds `r get_ogc_params("time-series-metadata")$thresholds`
#' @param unit_of_measure `r get_ogc_params("time-series-metadata")$unit_of_measure`
#' @param primary
Expand All @@ -47,6 +39,12 @@
#' @param time_series_id `r get_ogc_params("time-series-metadata")$id`
#' @param \dots Not used. Included to help differentiate official Water Data API arguments
#' from more seldom used, optional dataRetrieval-specific arguments.
#' @param begin_utc Deprecated in v1. Use "begin" instead.
#' @param end_utc Deprecated in v1. Use "end" instead.
#' @param state_name Deprecated in v1. Use `read_waterdata_combined_meta` for
#' similar functionality.
#' @param hydrologic_unit_code Deprecated in v1. Use
#' `read_waterdata_combined_meta` for similar functionality.
#' @inheritParams check_arguments_api
#' @inheritParams check_arguments_non_api
#'
Expand All @@ -63,8 +61,8 @@
#' parameter_code = c("00060", "00010"),
#' properties = c("monitoring_location_id",
#' "parameter_code",
#' "begin_utc",
#' "end_utc",
#' "begin",
#' "end",
#' "time_series_id"),
#' skipGeometry = TRUE)
#'
Expand Down Expand Up @@ -105,6 +103,44 @@ read_waterdata_ts_meta <- function(
output_id <- "time_series_id"
rlang::check_dots_empty()

on.exit(options("dataRetrieval.api_version" = "v1"))

if (!is.na(state_name)) {
warning(
"state_name is deprecated starting in v1 of the Water Data APIs.
Use the function read_waterdata_combined_meta instead.
Reverting to v0 version of Water Data APIs."
)

@ehinman ehinman Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a planned date for when they'll be removed entirely? If we have a date, might be handy to put here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~June, but I'm trying to thread the needle of not freaking people out about V0 (which is mostly a non-event) before WaterServices is decommissioned (which is a much bigger event) -- so we haven't announced more specifics than that yet. (I also haven't thought about it a ton yet, either)

options("dataRetrieval.api_version" = "v0")
}

if (!is.na(hydrologic_unit_code)) {
warning(
"hydrologic_unit_code is deprecated starting in v1 of the Water Data APIs.
Use the function read_waterdata_combined_meta instead.
Reverting to v0 version of Water Data APIs."
)
options("dataRetrieval.api_version" = "v0")
}

if (!is.na(begin_utc)) {
warning(
"begin_utc is deprecated starting in v1 of the Water Data APIs.
Use begin instead.
Reverting to v0 version of Water Data APIs."
)
options("dataRetrieval.api_version" = "v0")
}

if (!is.na(end_utc)) {
warning(
"end_utc is deprecated starting in v1 of the Water Data APIs.
Use end instead.
Reverting to v0 version of Water Data APIs."
)
options("dataRetrieval.api_version" = "v0")
}

args <- mget(names(formals()))
return_list <- get_ogc_data(args, output_id, service)

Expand Down
Loading
Loading