Skip to content

Commit 0fb8078

Browse files
authored
Merge branch 'DOI-USGS:main' into statistics
2 parents f1159d5 + bf8f276 commit 0fb8078

File tree

7 files changed

+4
-109
lines changed

7 files changed

+4
-109
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export(checkWQPdates)
66
export(check_OGC_requests)
77
export(check_waterdata_sample_params)
88
export(constructNWISURL)
9-
export(constructUseURL)
109
export(constructWQPURL)
1110
export(construct_api_requests)
1211
export(construct_waterdata_sample_request)

R/constructNWISURL.R

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
#' provide statistics for each month and year within the range individually.
3636
#' @param statType character Only used for statistics service requests. Type(s)
3737
#' of statistics to output for daily values. Default is mean, which is the only
38-
#' option for monthly and yearly report types. See the statistics service documentation
39-
#' at <https://waterservices.usgs.gov/docs/statistics/> for a
40-
#' full list of codes.
38+
#' option for monthly and yearly report types.
4139
#' @keywords data import USGS web service
4240
#' @return url string
4341
#' @export
@@ -431,63 +429,4 @@ constructWQPURL <- function(siteNumbers,
431429
return(baseURL)
432430
}
433431

434-
#' Construct URL for NWIS water use data service
435-
#'
436-
#' Reconstructs URLs to retrieve data from here: <https://waterdata.usgs.gov/nwis/wu>
437-
#'
438-
#' @param years integer Years for data retrieval. Must be years ending in 0 or 5,
439-
#' or "ALL", which retrieves all available years.
440-
#' @param stateCd could be character (full name, abbreviation, id), or numeric (id)
441-
#' @param countyCd could be numeric (County IDs from countyCdLookup) or character ("ALL")
442-
#' @param categories character Two-letter cateogory abbreviation(s)
443-
#' @return url string
444-
#' @export
445-
#' @examples
446-
#' url <- constructUseURL(
447-
#' years = c(1990, 1995),
448-
#' stateCd = "Ohio",
449-
#' countyCd = c(1, 3),
450-
#' categories = "ALL"
451-
#' )
452-
#'
453-
constructUseURL <- function(years, stateCd, countyCd, categories) {
454-
455-
456-
if (is.null(stateCd)) {
457-
baseURL <- httr2::request(pkg.env[["useNat"]])
458-
baseURL <- httr2::req_url_query(baseURL,
459-
format = "rdb",
460-
rdb_compression = "value")
461-
} else {
462-
463-
stateCd <- stateCdLookup(input = stateCd, outputType = "postal")
464-
baseURL <- httr2::request("https://waterdata.usgs.gov/")
465-
baseURL <- httr2::req_url_path_append(baseURL, stateCd)
466-
baseURL <- httr2::req_url_path_append(baseURL,
467-
"nwis", "water_use")
468-
baseURL <- httr2::req_url_query(baseURL,
469-
format = "rdb",
470-
rdb_compression = "value")
471-
472-
if (!(is.null(countyCd) )) {
473-
474-
baseURL <- httr2::req_url_query(baseURL,
475-
wu_area = "county")
476-
baseURL <- httr2::req_url_query(baseURL,
477-
wu_county = countyCd,
478-
.multi = "comma")
479-
} else {
480-
baseURL <- httr2::req_url_query(baseURL,
481-
wu_area = "State Total")
482-
}
483-
}
484432

485-
baseURL <- httr2::req_url_query(baseURL,
486-
wu_year = years,
487-
.multi = "comma")
488-
baseURL <- httr2::req_url_query(baseURL,
489-
wu_category = categories,
490-
.multi = "comma")
491-
492-
return(baseURL)
493-
}

R/setAccess.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Please contact comptools@usgs.gov for more information.")
5656
pkg.env$useNat <- "https://waterdata.usgs.gov/nwis/water_use"
5757
pkg.env$pCode <- "https://help.waterdata.usgs.gov/code/parameter_cd_query"
5858
pkg.env$pCodeSingle <- "https://help.waterdata.usgs.gov/code/parameter_cd_nm_query"
59-
# NOTE: state water use are still in: constructUseURL
59+
6060

6161
pkg.env$Result <- "https://www.waterqualitydata.us/data/Result/search"
6262
pkg.env$Station <- "https://www.waterqualitydata.us/data/Station/search"

_pkgdown.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ reference:
149149
desc: Functions to create web queries
150150
contents:
151151
- constructNWISURL
152-
- constructUseURL
153152
- constructWQPURL
154153
- getQuerySummary
155154
- getWebServiceData

man/constructNWISURL.Rd

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/constructUseURL.Rd

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/testthat/tests_userFriendly_fxns.R

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,7 @@ test_that("Construct USGS urls", {
392392

393393
url_works_ml <- dataRetrieval:::walk_pages(url_ml)
394394
expect_true(nrow(url_works_ml) > 0)
395-
396-
url_use <- constructUseURL(
397-
years = c(1990, 1995),
398-
stateCd = "Ohio",
399-
countyCd = c(1, 3),
400-
categories = "ALL"
401-
)
402-
expect_equal(url_use$url, "https://waterdata.usgs.gov/OH/nwis/water_use?format=rdb&rdb_compression=value&wu_area=county&wu_county=1%2C3&wu_year=1990%2C1995&wu_category=ALL")
395+
403396
# nolint end
404397
})
405398

0 commit comments

Comments
 (0)