Skip to content

Develop #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 16, 2025
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: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ vignettes/Status.Rmd
vignettes/long_to_wide.Rmd
vignettes/join_by_closest.Rmd
vignettes/wqx3_development_plan.Rmd
vignettes/read_USGS_functions.Rmd
vignettes/read_waterdata_functions.Rmd
vignettes/dataretrieval_discrete_changes_images/*
^ci$
^public$
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
API_USGS_PAT: ${{ secrets.API_USGS_PAT }}
R_KEEP_PKG_SOURCE: yes
CUSTOM_DR_UA: 'GitHub_CI'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
API_USGS_PAT: ${{ secrets.API_USGS_PAT }}
CUSTOM_DR_UA: 'GitHub_CI'
steps:
- uses: actions/checkout@581d62f320f2a4043a1ea6ac77290c60d27485cc
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
API_USGS_PAT: ${{ secrets.API_USGS_PAT }}
R_KEEP_PKG_SOURCE: yes
CUSTOM_DR_UA: 'GitHub_CI'

Expand Down
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ variables:
NOT_CRAN: "true"
PAGES_OUTDIR: "$CI_PROJECT_DIR/public"
CUSTOM_DR_UA: "GitLab_CI"
API_USGS_PAT: "${API_USGS_PAT}"

build-image:
stage: build
Expand Down
14 changes: 8 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export(addWaterYear)
export(calcWaterYear)
export(checkWQPdates)
export(check_OGC_requests)
export(check_USGS_sample_params)
export(check_waterdata_sample_params)
export(constructNWISURL)
export(constructUseURL)
export(constructWQPURL)
export(construct_USGS_sample_request)
export(construct_api_requests)
export(construct_waterdata_sample_request)
export(countyCd)
export(countyCdLookup)
export(create_NWIS_bib)
Expand Down Expand Up @@ -44,16 +44,18 @@ export(readNWISuv)
export(readWQPdata)
export(readWQPqw)
export(readWQPsummary)
export(read_USGS_daily)
export(read_USGS_data)
export(read_USGS_monitoring_location)
export(read_USGS_samples)
export(read_USGS_ts_meta)
export(read_waterdata)
export(read_waterdata_daily)
export(read_waterdata_monitoring_location)
export(read_waterdata_samples)
export(read_waterdata_ts_meta)
export(renameNWISColumns)
export(setAccess)
export(stateCd)
export(stateCdLookup)
export(summarize_USGS_samples)
export(summarize_waterdata_samples)
export(whatNWISdata)
export(whatNWISsites)
export(whatWQPdata)
Expand Down
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
dataRetrieval 2.7.19
===================
* Added read_USGS_daily, read_USGS_monitoring_location, read_USGS_ts_meta to access
* Added read_waterdata_daily, read_waterdata_monitoring_location, read_waterdata_ts_meta to access
new USGS web services.
* Added whisker and sf as dependencies.
* Renamed read_USGS_samples to read_waterdata_samples.
* Renamed summarize_USGS_samples to summarize_waterdata_samples.
* Added warning to setAccess for non-public endpoints.

dataRetrieval 2.7.18
===================
Expand Down
4 changes: 2 additions & 2 deletions R/dataRetrievals-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ NULL
#' US State Code Lookup Table
#'
#' Classic lookup table for states. Has been replaced in functions with
#' `check_USGS_sample_params("states")`.
#' `check_waterdata_sample_params("states")`.
#'
#' @name stateCd
#' @return stateCd data frame.
Expand All @@ -118,7 +118,7 @@ NULL
#' US County Code Lookup Table
#'
#' Classic lookup table for counties. Has been replaced in functions with
#' `check_USGS_sample_params("counties")`.
#' `check_USGS_waterdata_params("counties")`.
#'
#' @name countyCd
#' @return countyCd data frame.
Expand Down
14 changes: 7 additions & 7 deletions R/readNWISdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#' queryTime \tab POSIXct \tab The time the data was returned \cr
#' }
#'
#' @seealso [read_USGS_data()]
#' @seealso [read_waterdata()]
#' @export
#' @examplesIf is_dataRetrieval_user()
#' \donttest{
Expand Down Expand Up @@ -189,14 +189,14 @@ for more information.
https://cran.r-project.org/web/packages/dataRetrieval/vignettes/qwdata_changes.html"
)
} else if (service == "dv"){
.Deprecated(new = "read_USGS_daily",
.Deprecated(new = "read_waterdata_daily",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_USGS_daily.")
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_daily.")

} else if (service == "site"){
.Deprecated(new = "read_USGS_monitoring_location",
.Deprecated(new = "read_waterdata_monitoring_location",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_USGS_monitoring_location")
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_monitoring_location")
} else {
message(new_nwis_message())
}
Expand Down Expand Up @@ -288,7 +288,7 @@ stateCdLookup <- function(input,
outputType <- match.arg(outputType, c("postal", "fullName",
"id", "fips"))

states <- check_USGS_sample_params("states")
states <- check_waterdata_sample_params("states")
country <- match.arg(country, choices = unique(states$countryCode),
several.ok = FALSE)
states <- states[states$countryCode == country,]
Expand Down Expand Up @@ -360,7 +360,7 @@ countyCdLookup <- function(state, county, outputType = "fips") {
stop("Only one state allowed in countyCdLookup.")
}

counties <- check_USGS_sample_params("counties")
counties <- check_waterdata_sample_params("counties")

# first turn state into stateCd postal name
state_postal <- stateCdLookup(state,
Expand Down
8 changes: 4 additions & 4 deletions R/readNWISdv.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
#' queryTime \tab POSIXct \tab The time the data was returned \cr
#' }
#'
#' @seealso [read_USGS_daily()]
#' @seealso [read_waterdata_daily()]
#' @export
#' @keywords data import USGS web service
#' @examples
#'
#' # see ?read_USGS_daily
#' # see ?read_waterdata_daily
#'
#' #site_id <- "04085427"
#' #startDate <- "2012-01-01"
Expand All @@ -69,9 +69,9 @@ readNWISdv <- function(siteNumbers,
endDate = "",
statCd = "00003") {

.Deprecated(new = "read_USGS_daily",
.Deprecated(new = "read_waterdata_daily",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_USGS_daily.")
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_daily.")

url <- constructNWISURL(
siteNumbers = siteNumbers,
Expand Down
8 changes: 4 additions & 4 deletions R/readNWISsite.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@
#' comment \tab character \tab Header comments from the RDB file \cr
#' }
#' @export
#' @seealso [read_USGS_monitoring_location()]
#' @seealso [read_waterdata_monitoring_location()]
#' @examples
#'
#' # see ?read_USGS_monitoring_location
#' # see ?read_waterdata_monitoring_location
#' # siteINFOMulti <- readNWISsite(c("05114000", "09423350"))
#'
readNWISsite <- function(siteNumbers) {

.Deprecated(new = "read_USGS_monitoring_location",
.Deprecated(new = "read_waterdata_monitoring_location",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_USGS_monitoring_location")
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_monitoring_location")


baseURL <- httr2::request(pkg.env[["site"]])
Expand Down
8 changes: 3 additions & 5 deletions R/read_USGS_data.R → R/read_waterdata.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Generalized USGS data retrieval function
#' Generalized USGS Water Data API retrieval function
#'
#' Function that allows complex CQL queries.
#' See <https://api.waterdata.usgs.gov/docs/ogcapi/complex-queries/>
Expand Down Expand Up @@ -34,17 +34,15 @@
#' ]
#' }'
#'
#' dv_data <- read_USGS_data(service = "daily",
#' dv_data <- read_waterdata(service = "daily",
#' CQL = cql,
#' time = c("2023-01-01", "2024-01-01"))
#'
#' }
read_USGS_data <- function(service,
read_waterdata <- function(service,
CQL,
...,
convertType = TRUE){

message("Function in development, use at your own risk.")

query_req <- get_collection()

Expand Down
14 changes: 6 additions & 8 deletions R/read_USGS_daily.R → R/read_waterdata_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,33 @@
#' \donttest{
#' site <- "USGS-02238500"
#' pcode <- "00060"
#' dv_data_sf <- read_USGS_daily(monitoring_location_id = site,
#' dv_data_sf <- read_waterdata_daily(monitoring_location_id = site,
#' parameter_code = "00060",
#' time = c("2021-01-01", "2022-01-01"))
#'
#' dv_data_trim <- read_USGS_daily(monitoring_location_id = site,
#' dv_data_trim <- read_waterdata_daily(monitoring_location_id = site,
#' parameter_code = "00060",
#' properties = c("monitoring_location_id",
#' "value",
#' "time"),
#' time = c("2021-01-01", "2022-01-01"))
#'
#' dv_data <- read_USGS_daily(monitoring_location_id = site,
#' dv_data <- read_waterdata_daily(monitoring_location_id = site,
#' parameter_code = "00060",
#' skipGeometry = TRUE)
#'
#' dv_data_period <- read_USGS_daily(monitoring_location_id = site,
#' dv_data_period <- read_waterdata_daily(monitoring_location_id = site,
#' parameter_code = "00060",
#' time = "P7D")
#'
#' multi_site <- read_USGS_daily(monitoring_location_id = c("USGS-01491000",
#' multi_site <- read_waterdata_daily(monitoring_location_id = c("USGS-01491000",
#' "USGS-01645000"),
#' parameter_code = c("00060", "00010"),
#' limit = 500,
#' time = c("2023-01-01", "2024-01-01"))
#'
#' }
read_USGS_daily <- function(monitoring_location_id = NA_character_,
read_waterdata_daily <- function(monitoring_location_id = NA_character_,
parameter_code = NA_character_,
statistic_id = NA_character_,
properties = NA_character_,
Expand All @@ -84,8 +84,6 @@ read_USGS_daily <- function(monitoring_location_id = NA_character_,
max_results = NA,
convertType = TRUE){

message("Function in development, use at your own risk.")

service <- "daily"
output_id <- "daily_id"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,30 @@
#'
#' \donttest{
#' site <- "USGS-02238500"
#' site_info <- read_USGS_monitoring_location(monitoring_location_id = site)
#' site_info <- read_waterdata_monitoring_location(monitoring_location_id = site)
#'
#' site_slim <- read_USGS_monitoring_location(monitoring_location_id = site,
#' site_slim <- read_waterdata_monitoring_location(monitoring_location_id = site,
#' properties = c("monitoring_location_id",
#' "state_name",
#' "country_name"))
#'
#' site_slim_no_sf_slim <- read_USGS_monitoring_location(monitoring_location_id = site,
#' site_slim_no_sf_slim <- read_waterdata_monitoring_location(monitoring_location_id = site,
#' properties = c("monitoring_location_id",
#' "state_name",
#' "country_name"),
#' skipGeometry = TRUE)
#'
#' site_info_no_sf <- read_USGS_monitoring_location(monitoring_location_id = site,
#' site_info_no_sf <- read_waterdata_monitoring_location(monitoring_location_id = site,
#' skipGeometry = TRUE)
#'
#' bbox_vals = c(-94.00, 35.0, -93.5, 35.5)
#' multi_site <- read_USGS_monitoring_location(bbox = bbox_vals)
#' multi_site_n_100 <- read_USGS_monitoring_location(bbox = bbox_vals,
#' multi_site <- read_waterdata_monitoring_location(bbox = bbox_vals)
#' multi_site_n_100 <- read_waterdata_monitoring_location(bbox = bbox_vals,
#' max_results = 100)
#' multi_site_limit_100 <- read_USGS_monitoring_location(bbox = bbox_vals,
#' multi_site_limit_100 <- read_waterdata_monitoring_location(bbox = bbox_vals,
#' limit = 100)
#' }
read_USGS_monitoring_location <- function(monitoring_location_id = NA_character_,
read_waterdata_monitoring_location <- function(monitoring_location_id = NA_character_,
agency_code = NA_character_,
agency_name = NA_character_,
monitoring_location_number = NA_character_,
Expand Down Expand Up @@ -134,9 +134,7 @@ read_USGS_monitoring_location <- function(monitoring_location_id = NA_character_
limit = NA,
max_results = NA,
skipGeometry = NA){

message("Function in development, use at your own risk.")


service <- "monitoring-locations"
output_id <- "monitoring_location_id"

Expand Down
Loading
Loading