Skip to content
Merged
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: 0 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
on:
push:
branches: [main]
pull_request:
branches: [main]

name: pkgdown

Expand All @@ -22,6 +20,7 @@ concurrency:

jobs:
pkgdown:
if: github.repository == 'DOI-USGS/dataRetrieval'
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
environment: CI_config
Expand Down Expand Up @@ -64,13 +63,12 @@ jobs:
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create public directory
run: |
mkdir public
export API_USGS_PAT
- name: Build site
run: |
pkgdown::build_site(override = list(destination = "public")) |
Expand Down
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ variables:
PAGES_OUTDIR: "$CI_PROJECT_DIR/public"
CUSTOM_DR_UA: "GitLab_CI"
API_USGS_PAT: "${API_USGS_PAT}"
BUILDX_NO_DEFAULT_ATTESTATIONS: 1

build-package:
stage: build-package
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: dataRetrieval
Type: Package
Title: Retrieval Functions for USGS and EPA Hydrology and Water Quality Data
Version: 2.7.26
Version: 2.7.27
Authors@R: c(
person("Laura", "DeCicco", role = c("aut","cre"),
email = "ldecicco@usgs.gov",
Expand Down 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.1.0
Config/roxygen2/version: 8.1.1
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export(readNWISpeak)
export(readNWISrating)
export(readNWISsite)
export(readNWISstat)
export(readNWISuse)
export(readNWISuv)
export(readWQPdata)
export(readWQPqw)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
dataRetrieval 2.7.27
===================
* All NWIS functions will now error out by default. NWIS servers will be taken offline February 22nd, 2027. Use override_error = TRUE to temporarily override this error.
* Added sublocation_identifier parameter to read_waterdata_field_measurements and read_waterdata_field_meta.
* Added method_category parameter to read_waterdata_continuous.
* Updated Water Data API informational links to v1.

dataRetrieval 2.7.26
===================
* Switching to v1 of the Water Data APIs.
Expand Down
8 changes: 1 addition & 7 deletions R/constructNWISURL.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ constructNWISURL <- function(
},
stat = {
# for statistics service

message(
"Please be aware the NWIS data service feeding this function is in BETA.\n
Data formatting could be changed at any time, and is not guaranteed"
)

# make sure only statTypes allowed for the statReportType are being requested
if (
!grepl("(?i)daily", statReportType) &&
Expand Down Expand Up @@ -327,7 +321,7 @@ constructWQPURL <- function(

pCodeLogic <- TRUE

POST = nchar(paste0(siteNumbers, collapse = "")) > 2048
POST <- nchar(paste0(siteNumbers, collapse = "")) > 2048

if (!allPCode) {
multiplePcodes <- length(parameterCd) > 1
Expand Down
191 changes: 91 additions & 100 deletions R/readNWISdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#' "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 `OlsonNames()`
#' for more information on time zones.
#' @param override_error Logical parameter that allows users to run this
#' function during the final stages of NWIS decommission. NWIS servers will be taken
#' offline February 22nd, 2027. Setting this parameter to `TRUE` should only
#' be used as a tool to convert readNWIS to read_waterdata functions.
#' @param \dots see <https://waterservices.usgs.gov/docs/site-service/> for
#' a complete list of options. A
#' list of arguments can also be supplied. One important argument to include is
Expand Down Expand Up @@ -76,121 +80,108 @@ readNWISdata <- function(
...,
asDateTime = TRUE,
convertType = TRUE,
tz = "UTC"
tz = "UTC",
override_error = FALSE
) {
tz <- match.arg(tz, OlsonNames())

valuesList <- readNWISdots(...)

values <- valuesList[["values"]]
values <- values[names(values) != "format"]
format <- valuesList[["values"]][["format"]]

service <- valuesList$service
if (length(service) > 1) {
if (override_error) {
warning(
"Only one service value is allowed. Service: ",
service[1],
" will be used."
"NWIS servers will be taken offline February 22nd, 2027. Update to read_waterdata functions."
)
service <- service[1]
}

if (any(service %in% c("qw", "qwdata"))) {
.Deprecated(
old = "readNWISdata",
package = "dataRetrieval",
new = "readWQPdata",
msg = "NWIS qw web services are being retired.
Please see vignette('qwdata_changes', package = 'dataRetrieval')
for more information.
https://cran.r-project.org/web/packages/dataRetrieval/vignettes/qwdata_changes.html"
)
} else if (service == "dv") {
.Deprecated(
new = "read_waterdata_daily",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_daily."
)
} else if (service == "site") {
.Deprecated(
new = "read_waterdata_monitoring_location",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_monitoring_location"
)
} else {
message(new_nwis_message())
}
tz <- match.arg(tz, OlsonNames())

baseURL <- httr2::request(pkg.env[[service]])
valuesList <- readNWISdots(...)

POST <- nchar(paste0(unlist(values), collapse = "")) > 2048
values <- valuesList[["values"]]
values <- values[names(values) != "format"]
format <- valuesList[["values"]][["format"]]

baseURL <- get_or_post(baseURL, POST = POST, !!!values, .multi = "comma")
service <- valuesList$service
if (length(service) > 1) {
warning(
"Only one service value is allowed. Service: ",
service[1],
" will be used."
)
service <- service[1]
}

if (service != "rating") {
baseURL <- get_or_post(baseURL, POST = POST, format = format)
}
baseURL <- httr2::request(pkg.env[[service]])

if (length(grep("rdb", format)) > 0) {
retval <- importRDB1(
baseURL,
tz = tz,
asDateTime = asDateTime,
convertType = convertType
)
} else {
retval <- importWaterML1(baseURL, tz = tz, asDateTime = asDateTime)
}
POST <- nchar(paste0(unlist(values), collapse = "")) > 2048

baseURL <- get_or_post(baseURL, POST = POST, !!!values, .multi = "comma")

if (service != "rating") {
baseURL <- get_or_post(baseURL, POST = POST, format = format)
}

if ("dv" == service) {
tzLib <- stats::setNames(
c(
"America/New_York",
"America/New_York",
"America/Chicago",
"America/Chicago",
"America/Denver",
"America/Denver",
"America/Los_Angeles",
"America/Los_Angeles",
"America/Anchorage",
"America/Anchorage",
"America/Honolulu",
"America/Honolulu",
"UTC"
),
c(
"EST",
"EDT",
"CST",
"CDT",
"MST",
"MDT",
"PST",
"PDT",
"AKST",
"AKDT",
"HAST",
"HST",
"UTC"
if (length(grep("rdb", format)) > 0) {
retval <- importRDB1(
baseURL,
tz = tz,
asDateTime = asDateTime,
convertType = convertType
)
)
# TODO: Think about dates that cross a time zone boundary.
if (format == "waterml,1.1" && nrow(retval) > 0) {
retval$dateTime <- as.POSIXct(
retval$dateTime,
tzLib[tz = retval$tz_cd[1]]
} else {
retval <- importWaterML1(baseURL, tz = tz, asDateTime = asDateTime)
}

if ("dv" == service) {
tzLib <- stats::setNames(
c(
"America/New_York",
"America/New_York",
"America/Chicago",
"America/Chicago",
"America/Denver",
"America/Denver",
"America/Los_Angeles",
"America/Los_Angeles",
"America/Anchorage",
"America/Anchorage",
"America/Honolulu",
"America/Honolulu",
"UTC"
),
c(
"EST",
"EDT",
"CST",
"CDT",
"MST",
"MDT",
"PST",
"PDT",
"AKST",
"AKDT",
"HAST",
"HST",
"UTC"
)
)
# TODO: Think about dates that cross a time zone boundary.
if (format == "waterml,1.1" && nrow(retval) > 0) {
retval$dateTime <- as.POSIXct(
retval$dateTime,
tzLib[tz = retval$tz_cd[1]]
)
}
}
}

if ("iv" == service || "iv_recent" == service) {
if (tz == "") {
retval$tz_cd <- rep("UTC", nrow(retval))
} else {
retval$tz_cd <- rep(tz, nrow(retval))
if ("iv" == service || "iv_recent" == service) {
if (tz == "") {
retval$tz_cd <- rep("UTC", nrow(retval))
} else {
retval$tz_cd <- rep(tz, nrow(retval))
}
}
} else {
stop(
"NWIS servers will be taken offline February 22nd, 2027. Update to read_waterdata functions.
Use override_error = TRUE to temporarily override this error. For more information:
https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html"
)
}

return(retval)
Expand Down
Loading
Loading