|
35 | 35 | #' provide statistics for each month and year within the range individually. |
36 | 36 | #' @param statType character Only used for statistics service requests. Type(s) |
37 | 37 | #' 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. |
41 | 39 | #' @keywords data import USGS web service |
42 | 40 | #' @return url string |
43 | 41 | #' @export |
@@ -431,63 +429,4 @@ constructWQPURL <- function(siteNumbers, |
431 | 429 | return(baseURL) |
432 | 430 | } |
433 | 431 |
|
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 | | - } |
484 | 432 |
|
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 | | -} |
0 commit comments