Skip to content

Commit 6d8dd47

Browse files
Merge pull request #800 from ldecicco-USGS/latest_cont
Latest cont
2 parents 591034e + 6c14db3 commit 6d8dd47

File tree

7 files changed

+437
-163
lines changed

7 files changed

+437
-163
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export(readWQPsummary)
4747
export(read_USGS_samples)
4848
export(read_waterdata)
4949
export(read_waterdata_daily)
50+
export(read_waterdata_latest_continuous)
5051
export(read_waterdata_monitoring_location)
5152
export(read_waterdata_samples)
5253
export(read_waterdata_ts_meta)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#' Get Latest Continuous USGS Water Data
2+
#'
3+
#' Description `r get_description("latest-continuous")`
4+
#'
5+
#' @export
6+
#' @param monitoring_location_id `r get_params("latest-continuous")$monitoring_location_id`
7+
#' @param parameter_code `r get_params("latest-continuous")$parameter_code`
8+
#' @param statistic_id `r get_params("latest-continuous")$statistic_id`
9+
#' @param time `r get_params("latest-continuous")$time`
10+
#' @param value `r get_params("latest-continuous")$value`
11+
#' @param unit_of_measure `r get_params("latest-continuous")$unit_of_measure`
12+
#' @param approval_status `r get_params("latest-continuous")$approval_status`
13+
#' @param last_modified `r get_params("latest-continuous")$last_modified`
14+
#' @param time_series_id `r get_params("latest-continuous")$time_series_id`
15+
#' @param qualifier `r get_params("latest-continuous")$qualifier`
16+
#' @param daily_id `r get_params("latest-continuous")$id`
17+
#' @param properties A vector of requested columns to be returned from the query.
18+
#' Available options are:
19+
#' `r schema <- check_OGC_requests(endpoint = "latest-continuous", type = "schema"); paste(names(schema$properties), collapse = ", ")`
20+
#' @param bbox Only features that have a geometry that intersects the bounding
21+
#' box are selected.The bounding box is provided as four or six numbers, depending
22+
#' on whether the coordinate reference system includes a vertical axis (height or
23+
#' depth). Coordinates are assumed to be in crs 4326. The expected format is a numeric
24+
#' vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude,
25+
#' Southern-most latitude, Eastern-most longitude, Northern-most longitude).
26+
#' @param limit The optional limit parameter is used to control the subset of the
27+
#' selected features that should be returned in each page. The maximum allowable
28+
#' limit is 10000. It may be beneficial to set this number lower if your internet
29+
#' connection is spotty. The default (`NA`) will set the limit to the maximum
30+
#' allowable limit for the service.
31+
#' @param max_results The optional maximum number of rows to return. This value
32+
#' must be less than the requested limit.
33+
#' @param skipGeometry This option can be used to skip response geometries for
34+
#' each feature. The returning object will be a data frame with no spatial
35+
#' information.
36+
#' @param convertType logical, defaults to `TRUE`. If `TRUE`, the function
37+
#' will convert the data to dates and qualifier to string vector.
38+
#' @examplesIf is_dataRetrieval_user()
39+
#'
40+
#' \donttest{
41+
#' site <- "USGS-451605097071701"
42+
#' pcode <- "72019"
43+
#' uv_data_sf <- read_waterdata_latest_continuous(monitoring_location_id = site,
44+
#' parameter_code = pcode)
45+
#'
46+
#' uv_data_trim <- read_waterdata_latest_continuous(monitoring_location_id = site,
47+
#' parameter_code = pcode,
48+
#' properties = c("monitoring_location_id",
49+
#' "value",
50+
#' "time"))
51+
#'
52+
#' uv_data <- read_waterdata_latest_continuous(monitoring_location_id = site,
53+
#' parameter_code = pcode,
54+
#' skipGeometry = TRUE)
55+
#'
56+
#' uv_data_period <- read_waterdata_latest_continuous(monitoring_location_id = site,
57+
#' parameter_code = pcode,
58+
#' time = "P7D")
59+
#'
60+
#' multi_site <- read_waterdata_latest_continuous(monitoring_location_id = c("USGS-451605097071701",
61+
#' "USGS-14181500"),
62+
#' parameter_code = c("00060", "72019"))
63+
#'
64+
#' }
65+
read_waterdata_latest_continuous <- function(monitoring_location_id = NA_character_,
66+
parameter_code = NA_character_,
67+
statistic_id = NA_character_,
68+
properties = NA_character_,
69+
time_series_id = NA_character_,
70+
daily_id = NA_character_,
71+
approval_status = NA_character_,
72+
unit_of_measure = NA_character_,
73+
qualifier = NA_character_,
74+
value = NA,
75+
last_modified = NA_character_,
76+
skipGeometry = NA,
77+
time = NA_character_,
78+
bbox = NA,
79+
limit = NA,
80+
max_results = NA,
81+
convertType = TRUE){
82+
83+
service <- "latest-continuous"
84+
output_id <- "latest_continuous_id"
85+
86+
args <- mget(names(formals()))
87+
return_list <- get_ogc_data(args,
88+
output_id,
89+
service)
90+
91+
return_list <- return_list[order(return_list$time, return_list$monitoring_location_id), ]
92+
93+
return(return_list)
94+
}
95+
96+
97+

README.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ The `dataRetrieval` package was created to simplify the process of loading hydro
3131

3232
# Introduction
3333

34-
:warning: USGS discrete water-quality data availability and format are changing. Beginning March 11, 2024 USGS data obtained from legacy services will not include new USGS data or recent updates to existing data. To view the status of changes in data availability and code functionality, visit: <https://doi-usgs.github.io/dataRetrieval/articles/Status.html>
34+
:warning: NWIS web services (readNWIS functions) will be replaced over time by USGS Water Data APIs (read_waterdata_). Read more about it here:
35+
<https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html>
36+
37+
:warning: USGS discrete water-quality data availability and format are changing. To view the status of changes in data availability and code functionality, visit: <https://doi-usgs.github.io/dataRetrieval/articles/Status.html>
3538

3639
If you have additional questions about these changes, email [email protected].
3740

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ Environmental Protection Agency (EPA), U.S. Department of Agriculture
1515

1616
# Introduction
1717

18+
:warning: NWIS web services (readNWIS functions) will be replaced over
19+
time by USGS Water Data APIs (read_waterdata\_). Read more about it
20+
here:
21+
<https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html>
22+
1823
:warning: USGS discrete water-quality data availability and format are
19-
changing. Beginning March 11, 2024 USGS data obtained from legacy
20-
services will not include new USGS data or recent updates to existing
21-
data. To view the status of changes in data availability and code
24+
changing. To view the status of changes in data availability and code
2225
functionality, visit:
2326
<https://doi-usgs.github.io/dataRetrieval/articles/Status.html>
2427

@@ -193,14 +196,14 @@ NWIScitation
193196
#> U.S. Geological Survey (2025). _National Water Information System data
194197
#> available on the World Wide Web (USGS Water Data for the Nation)_.
195198
#> doi:10.5066/F7P55KJN <https://doi.org/10.5066/F7P55KJN>, Accessed Jun
196-
#> 13, 2025,
199+
#> 27, 2025,
197200
#> <https://waterservices.usgs.gov/nwis/dv/?site=09010500&format=waterml%2C1.1&ParameterCd=00060&StatCd=00003&startDT=1851-01-01>.
198201
print(NWIScitation, style = "Bibtex")
199202
#> @Manual{,
200203
#> title = {National Water Information System data available on the World Wide Web (USGS Water Data for the Nation)},
201204
#> author = {{U.S. Geological Survey}},
202205
#> doi = {10.5066/F7P55KJN},
203-
#> note = {Accessed Jun 13, 2025},
206+
#> note = {Accessed Jun 27, 2025},
204207
#> year = {2025},
205208
#> url = {https://waterservices.usgs.gov/nwis/dv/?site=09010500&format=waterml%2C1.1&ParameterCd=00060&StatCd=00003&startDT=1851-01-01},
206209
#> }
@@ -224,14 +227,14 @@ WQPcitation <- create_WQP_bib(SC)
224227
WQPcitation
225228
#> National Water Quality Monitoring Council (2025). _Water Quality
226229
#> Portal_. doi:10.5066/P9QRKUVJ <https://doi.org/10.5066/P9QRKUVJ>,
227-
#> Accessed Jun 13, 2025,
230+
#> Accessed Jun 27, 2025,
228231
#> <https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&count=no&pCode=00300&mimeType=csv>.
229232
print(WQPcitation, style = "Bibtex")
230233
#> @Manual{,
231234
#> title = {Water Quality Portal},
232235
#> author = {{National Water Quality Monitoring Council}},
233236
#> doi = {10.5066/P9QRKUVJ},
234-
#> note = {Accessed Jun 13, 2025},
237+
#> note = {Accessed Jun 27, 2025},
235238
#> year = {2025},
236239
#> url = {https://www.waterqualitydata.us/data/Result/search?siteid=USGS-05288705&count=no&pCode=00300&mimeType=csv},
237240
#> }

_pkgdown.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ navbar:
6464
- icon: fa-github fa-lg
6565
href: https://github.com/DOI-USGS/dataRetrieval
6666
reference:
67-
- title: USGS new data services
68-
desc: Functions to retrieve USGS data from new services.
67+
- title: USGS Water Data
68+
desc: Functions to retrieve USGS Water Data APIs.
6969
contents:
7070
- read_waterdata_samples
7171
- read_waterdata_daily
7272
- read_waterdata_ts_meta
7373
- read_waterdata_monitoring_location
74+
- read_waterdata_latest_continuous
7475
- read_waterdata
7576
- summarize_waterdata_samples
7677
- check_waterdata_sample_params

man/read_waterdata_latest_continuous.Rd

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)