Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4d3ed55
First pass
ldecicco-USGS Nov 24, 2025
2737c28
missed again
ldecicco-USGS Nov 24, 2025
c26941d
Merge branch 'develop' of https://code.usgs.gov/water/dataRetrieval i…
ldecicco-USGS Nov 24, 2025
ce54d74
First pass
ldecicco-USGS Nov 26, 2025
9472c9b
add note
ldecicco-USGS Nov 26, 2025
1df87c3
Update docs
ldecicco-USGS Nov 26, 2025
aea1c58
pkgdown
ldecicco-USGS Nov 26, 2025
b7825d2
Limit bumped
ldecicco-USGS Dec 1, 2025
7a46151
Update tests
ldecicco-USGS Dec 1, 2025
04b7e49
No bbox for continuous
ldecicco-USGS Dec 2, 2025
c66862e
Update docs
ldecicco-USGS Dec 3, 2025
64bd04d
cleanup language
ldecicco-USGS Dec 3, 2025
6f676ca
More wordsmithing.
ldecicco-USGS Dec 3, 2025
bed2283
Add a targets example
ldecicco-USGS Dec 3, 2025
57132a4
don't evaluate targets stuff
ldecicco-USGS Dec 3, 2025
99186ce
proper links
ldecicco-USGS Dec 3, 2025
d636c59
bad link
ldecicco-USGS Dec 3, 2025
85568c4
Update R/walk_pages.R
ldecicco-USGS Dec 4, 2025
ef26a2f
Update vignettes/dataRetrieval.Rmd
ldecicco-USGS Dec 4, 2025
bf6878f
Update tutorials/basic_slides_deck.qmd
ldecicco-USGS Dec 4, 2025
ebf37f6
Remove id columns from daily/continuous
ldecicco-USGS Dec 4, 2025
84c269e
Push id's to the far right.
ldecicco-USGS Dec 4, 2025
d28ed5e
updated news
ldecicco-USGS Dec 4, 2025
10e4106
fixed daily_id select
ldecicco-USGS Dec 4, 2025
015f7f3
Cleanup properties documentation
ldecicco-USGS Dec 4, 2025
f6912aa
Update vignettes/tutorial.Rmd
ldecicco-USGS Dec 4, 2025
c3272e7
NWIS words
ldecicco-USGS Dec 4, 2025
4bc21b6
Merge branch 'continuous' of github.com:ldecicco-USGS/dataRetrieval i…
ldecicco-USGS Dec 4, 2025
23f4f14
language
ldecicco-USGS Dec 4, 2025
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
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Authors@R: c(
email = "[email protected]",
comment=c(ORCID = "0000-0003-2521-5043")),
person("Lee", "Stanish", role="ctb",
email = "[email protected]",
comment=c(ORCID = "0000-0002-9775-6861")),
person("Joeseph", "Zemmels", role="ctb",
email = "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export(readWQPqw)
export(readWQPsummary)
export(read_USGS_samples)
export(read_waterdata)
export(read_waterdata_continuous)
export(read_waterdata_daily)
export(read_waterdata_field_measurements)
export(read_waterdata_latest_continuous)
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.22
===================
* Added read_waterdata_latest_daily to access latest daily USGS water data.
* Added read_waterdata_continuous to access continuous USGS water data.
* Added state_name and hydrologic_unit_code to read_waterdata_ts_meta

dataRetrieval 2.7.21
Expand Down
3 changes: 2 additions & 1 deletion R/AAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pkg.env <- new.env()

services <- c("server", "daily", "time-series-metadata",
"monitoring-locations", "latest-continuous",
"field-measurements", "latest-daily")
"field-measurements", "latest-daily",
"continuous")
collections <- c("parameter-codes", "agency-codes", "altitude-datums", "aquifer-codes",
"aquifer-types", "coordinate-accuracy-codes", "coordinate-datum-codes",
"coordinate-method-codes", "medium-codes",
Expand Down
2 changes: 1 addition & 1 deletion R/construct_api_requests.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ construct_api_requests <- function(service,
if(!is.na(max_results)){
get_list[["limit"]] <- max_results
} else {
get_list[["limit"]] <- 10000
get_list[["limit"]] <- 50000
}
} else {
if(!is.na(max_results)){
Expand Down
10 changes: 9 additions & 1 deletion R/readNWISunit.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ readNWISuv <- function(siteNumbers, parameterCd, startDate = "", endDate = "", t
service <- "iv_recent"
}

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


url <- constructNWISURL(siteNumbers,
parameterCd,
startDate,
Expand Down Expand Up @@ -360,7 +365,10 @@ readNWISmeas <- function(siteNumbers,
expanded = FALSE,
convertType = TRUE) {

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

# Doesn't seem to be a WaterML1 format option
url <- constructNWISURL(
siteNumbers = siteNumbers,
Expand Down
91 changes: 91 additions & 0 deletions R/read_waterdata_continuous.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#' Get Continuous USGS Water Data
#'
#' @description `r get_description("continuous")`
#'
#' Currently, the services only allow up to 3 years of data to be requested with
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a hard and fast rule?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Edit: asked Mike, got the answer. This is a helpful piece of info!

#' a single request. If no "time" is specified, the service will return the
#' last single year of data. If this is a bottleneck, please check back
#' for new direct download functions that are expected to be available sometime
#' in 2026.
#'
#' @export
#' @param monitoring_location_id `r get_params("continuous")$monitoring_location_id`
#' @param parameter_code `r get_params("continuous")$parameter_code`
#' @param statistic_id `r get_params("continuous")$statistic_id`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to self to test: is this really a valid input? Isn't the stat id for continuous 00011?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's a valid input, but only 00011 will return data. We could take it out of the argument list so hopefully it's less confusing? I'll double check there aren't some weird random other stat ids for continuous data.

#' @param time `r get_params("continuous")$time`
#' @param value `r get_params("continuous")$value`
#' @param unit_of_measure `r get_params("continuous")$unit_of_measure`
#' @param approval_status `r get_params("continuous")$approval_status`
#' @param last_modified `r get_params("continuous")$last_modified`
#' @param time_series_id `r get_params("continuous")$time_series_id`
#' @param qualifier `r get_params("continuous")$qualifier`
#' @param continuous_id `r get_params("continuous")$id`
#' @param properties A vector of requested columns to be returned from the query.
#' Available options are:
#' `r schema <- check_OGC_requests(endpoint = "continuous", type = "schema"); paste(names(schema$properties), collapse = ", ")`
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
#' must be less than the requested limit.
#' @param convertType logical, defaults to `TRUE`. If `TRUE`, the function
#' will convert the data to dates and qualifier to string vector.
#' @examplesIf is_dataRetrieval_user()
#'
#' \donttest{
#' site <- "USGS-451605097071701"
#' pcode <- "72019"
#'
#' uv_data_trim <- read_waterdata_continuous(monitoring_location_id = site,
#' parameter_code = pcode,
#' properties = c("monitoring_location_id",
#' "value",
#' "time"))
#'
#' uv_data <- read_waterdata_continuous(monitoring_location_id = site,
#' parameter_code = pcode,
#' time = "P2D")
#'
#'
#' # Only return data that has been modified in last 7 days
#' multi_site2 <- read_waterdata_continuous(monitoring_location_id = c("USGS-451605097071701",
#' "USGS-14181500"),
#' parameter_code = c("00060", "72019"),
#' last_modified = "P7D")
#'
#' }
read_waterdata_continuous <- function(monitoring_location_id = NA_character_,
parameter_code = NA_character_,
statistic_id = NA_character_,
properties = NA_character_,
time_series_id = NA_character_,
continuous_id = NA_character_,
approval_status = NA_character_,
unit_of_measure = NA_character_,
qualifier = NA_character_,
value = NA,
last_modified = NA_character_,
time = NA_character_,
limit = NA,
max_results = NA,
convertType = TRUE){

service <- "continuous"
output_id <- "continuous_id"

args <- mget(names(formals()))
args[["skipGeometry"]] <- TRUE

return_list <- get_ogc_data(args,
output_id,
service)

return_list <- return_list[order(return_list$time, return_list$monitoring_location_id), ]

return(return_list)
}



34 changes: 17 additions & 17 deletions R/read_waterdata_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down Expand Up @@ -71,22 +71,22 @@
#'
#' }
read_waterdata_daily <- function(monitoring_location_id = NA_character_,
parameter_code = NA_character_,
statistic_id = NA_character_,
properties = NA_character_,
time_series_id = NA_character_,
daily_id = NA_character_,
approval_status = NA_character_,
unit_of_measure = NA_character_,
qualifier = NA_character_,
value = NA,
last_modified = NA_character_,
skipGeometry = NA,
time = NA_character_,
bbox = NA,
limit = NA,
max_results = NA,
convertType = TRUE){
parameter_code = NA_character_,
statistic_id = NA_character_,
properties = NA_character_,
time_series_id = NA_character_,
daily_id = NA_character_,
approval_status = NA_character_,
unit_of_measure = NA_character_,
qualifier = NA_character_,
value = NA,
last_modified = NA_character_,
skipGeometry = NA,
time = NA_character_,
bbox = NA,
limit = NA,
max_results = NA,
convertType = TRUE){

service <- "daily"
output_id <- "daily_id"
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 @@ -27,7 +27,7 @@
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_latest_continuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_latest_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' "topographic-codes", "time-zone-codes".
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
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 @@ -54,7 +54,7 @@
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_parameter_codes.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' `r schema <- check_OGC_requests(endpoint = "parameter-codes", type = "schema"); paste(names(schema$properties), collapse = ", ")`.
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down
2 changes: 1 addition & 1 deletion R/read_waterdata_ts_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
#' @param limit The optional limit parameter is used to control the subset of the
#' selected features that should be returned in each page. The maximum allowable
#' limit is 10000. It may be beneficial to set this number lower if your internet
#' limit is 50000. It may be beneficial to set this number lower if your internet
#' connection is spotty. The default (`NA`) will set the limit to the maximum
#' allowable limit for the service.
#' @param max_results The optional maximum number of rows to return. This value
Expand Down
5 changes: 3 additions & 2 deletions R/walk_pages.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ cleanup_cols <- function(df, service = "daily"){
if("time" %in% names(df)){
if(service == "daily"){
df$time <- as.Date(df$time)
}
# leave some room here for POSIXct in the other services.
}
# by default, the data is put in POSITct and seems
# to be pretty smart about the offset/tzone
}

if("value" %in% names(df)){
Expand Down
4 changes: 3 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If you have additional questions about these changes, email [email protected].

# What would you like to do?

1. Get instantaneous USGS data (for example, discharge sensor data). Start here: `?readNWISuv`. If you only need the latest value, you can use the function: `?read_waterdata_latest_continuous`.
1. Get instantaneous USGS data (for example, discharge sensor data). Start here: `?read_waterdata_continuous`. If you only need the latest value, you can use the function: `?read_waterdata_latest_continuous`.

2. Get daily USGS data (for example, mean daily discharge). Start here: `?read_waterdata_daily`. If you only need the latest value, you can use the function: `?read_waterdata_latest_daily`.

Expand All @@ -56,6 +56,8 @@ If you have additional questions about these changes, email [email protected].

8. Add a USGS WaterData API token to your R environment. See: <https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html#api-tokens>

9. Get the latest status on NWIS and other data access updates. See: <https://doi-usgs.github.io/dataRetrieval/articles/Status.html>

For additional tutorials, see:

[Basic Tutorial](https://doi-usgs.github.io/dataRetrieval/articles/tutorial.html)
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ If you have additional questions about these changes, email
# What would you like to do?

1. Get instantaneous USGS data (for example, discharge sensor data).
Start here: `?readNWISuv`. If you only need the latest value, you
can use the function: `?read_waterdata_latest_continuous`.
Start here: `?read_waterdata_continuous`. If you only need the
latest value, you can use the function:
`?read_waterdata_latest_continuous`.

2. Get daily USGS data (for example, mean daily discharge). Start here:
`?read_waterdata_daily`. If you only need the latest value, you can
Expand All @@ -58,6 +59,9 @@ If you have additional questions about these changes, email
8. Add a USGS WaterData API token to your R environment. See:
<https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html#api-tokens>

9. Get the latest status on NWIS and other data access updates. See:
<https://doi-usgs.github.io/dataRetrieval/articles/Status.html>

For additional tutorials, see:

[Basic
Expand Down Expand Up @@ -198,15 +202,15 @@ NWIScitation <- create_NWIS_bib(dv)
NWIScitation
#> U.S. Geological Survey (2025). _National Water Information System data
#> available on the World Wide Web (USGS Water Data for the Nation)_.
#> doi:10.5066/F7P55KJN <https://doi.org/10.5066/F7P55KJN>, Accessed Nov
#> 24, 2025,
#> doi:10.5066/F7P55KJN <https://doi.org/10.5066/F7P55KJN>, Accessed Dec
#> 03, 2025,
#> <https://waterservices.usgs.gov/nwis/dv/?site=09010500&format=waterml%2C1.1&ParameterCd=00060&StatCd=00003&startDT=1851-01-01>.
print(NWIScitation, style = "Bibtex")
#> @Manual{,
#> title = {National Water Information System data available on the World Wide Web (USGS Water Data for the Nation)},
#> author = {{U.S. Geological Survey}},
#> doi = {10.5066/F7P55KJN},
#> note = {Accessed Nov 24, 2025},
#> note = {Accessed Dec 03, 2025},
#> year = {2025},
#> url = {https://waterservices.usgs.gov/nwis/dv/?site=09010500&format=waterml%2C1.1&ParameterCd=00060&StatCd=00003&startDT=1851-01-01},
#> }
Expand All @@ -230,14 +234,14 @@ WQPcitation <- create_WQP_bib(SC)
WQPcitation
#> National Water Quality Monitoring Council (2025). _Water Quality
#> Portal_. doi:10.5066/P9QRKUVJ <https://doi.org/10.5066/P9QRKUVJ>,
#> Accessed Nov 24, 2025,
#> Accessed Dec 03, 2025,
#> <https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&count=no&pCode=00300&mimeType=csv>.
print(WQPcitation, style = "Bibtex")
#> @Manual{,
#> title = {Water Quality Portal},
#> author = {{National Water Quality Monitoring Council}},
#> doi = {10.5066/P9QRKUVJ},
#> note = {Accessed Nov 24, 2025},
#> note = {Accessed Dec 03, 2025},
#> year = {2025},
#> url = {https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&count=no&pCode=00300&mimeType=csv},
#> }
Expand Down
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ reference:
contents:
- read_waterdata_samples
- read_waterdata_daily
- read_waterdata_continuous
- read_waterdata_ts_meta
- read_waterdata_monitoring_location
- read_waterdata_latest_continuous
- read_waterdata_latest_daily
- read_waterdata_field_measurements
- read_waterdata_parameter_codes
- read_waterdata_metadata
Expand Down
Loading
Loading