diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 38eef4aba..06e731e81 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -74,7 +74,8 @@ jobs: - name: Build site run: | pkgdown::build_site(override = list(destination = "public")) | - file.copy(from = "./public/articles/logo.png",to = "./public/reference/logo.png") + file.copy(from = "./public/articles/logo.png",to = "./public/reference/logo.png") | + file.copy(from = "./public/articles/logo.png", to = "./public/news/logo.png") shell: Rscript {0} - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@v2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 565ddcb1d..660a94752 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -141,7 +141,8 @@ pages: - | Rscript -e ' pkgdown::build_site(override = list(destination = "public")) - file.copy(from = "./public/articles/logo.png", to = "./public/reference/logo.png")' + file.copy(from = "./public/articles/logo.png", to = "./public/reference/logo.png") + file.copy(from = "./public/articles/logo.png", to = "./public/news/logo.png")' - quarto render artifacts: paths: diff --git a/DESCRIPTION b/DESCRIPTION index f9ba7fdf4..dba89ba8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dataRetrieval Type: Package Title: Retrieval Functions for USGS and EPA Hydrology and Water Quality Data -Version: 2.7.25 +Version: 2.7.26 Authors@R: c( person("Laura", "DeCicco", role = c("aut","cre"), email = "ldecicco@usgs.gov", @@ -34,7 +34,10 @@ Authors@R: c( comment=c(ORCID = "0000-0001-5396-1583")), person("Michael", "Mahoney", role="ctb", email = "mjmahoney@usgs.gov", - comment=c(ORCID = "0000-0003-2402-304X")) + comment=c(ORCID = "0000-0003-2402-304X")), + person("Matthew", "Conlon", role="ctb", + email = "mconlon@usgs.gov", + comment=c(ORCID = "0000-0001-8266-9610")) ) Description: Collection of functions to help retrieve U.S. Geological Survey and U.S. Environmental Protection Agency water quality and diff --git a/NAMESPACE b/NAMESPACE index 5db89fe84..002c070fb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,7 @@ export(create_NWIS_bib) export(create_WQP_bib) export(findNLDI) export(getWebServiceData) +export(get_monitoring_location_arguments) export(get_nldi_sources) export(get_ogc_params) export(importNGWMN) @@ -27,9 +28,6 @@ export(pCodeToName) export(parameterCdFile) export(parse_WQP) export(pcode_to_name) -export(readNGWMNdata) -export(readNGWMNlevels) -export(readNGWMNsites) export(readNWISdata) export(readNWISdv) export(readNWISpCode) @@ -43,6 +41,12 @@ export(readWQPdata) export(readWQPqw) export(readWQPsummary) export(read_USGS_samples) +export(read_ngwmn) +export(read_ngwmn_lithology) +export(read_ngwmn_providers) +export(read_ngwmn_sites) +export(read_ngwmn_water_level) +export(read_ngwmn_well_construction) export(read_waterdata) export(read_waterdata_channel) export(read_waterdata_combined_meta) @@ -52,6 +56,7 @@ export(read_waterdata_field_measurements) export(read_waterdata_field_meta) export(read_waterdata_latest_continuous) export(read_waterdata_latest_daily) +export(read_waterdata_latest_field_measurements) export(read_waterdata_metadata) export(read_waterdata_monitoring_location) export(read_waterdata_parameter_codes) diff --git a/NEWS b/NEWS.md similarity index 91% rename from NEWS rename to NEWS.md index 6795c745e..f1ca1457d 100644 --- a/NEWS +++ b/NEWS.md @@ -1,3 +1,13 @@ +dataRetrieval 2.7.26 +=================== +* Added suite of read_ngwmn to access new National Groundwater Monitoring +Network API. +* Created get_monitoring_location_arguments to help users understand +what new optional arguments are available in many of the read_waterdata functions. +* Added ability to use `...` in the Water Data functions for: daily, latest-continuous, field-measurements, latest-daily, latest-field-measurements, continuous, and peaks. The "..." argument can now accept any parameter that is output from the make_monitoring_location_arguments function. +* Added "q" argument to read_waterdata_monitoring_location. Full-text search across the most relevant text fields for this collection (e.g. site name, identifier, number, state, county, and site type). +* Added "skipGeometry" argument to read_waterdata_continuous. Previously geometry wasn't included with continuous data, but now is supported. + dataRetrieval 2.7.25 =================== * Added read_waterdata_ratings to access USGS rating curves with @@ -32,27 +42,27 @@ return full period of record. dataRetrieval 2.7.23 =================== -* Added data.table to Imports + * Added read_waterdata_stats_por and read_waterdata_stats_daterange to access USGS daily data statistics. -* Updated vignettes, examples, and README to reflect new stats functions. -* Added tests for read_waterdata_stats functions +* Added read_waterdata_field_meta, read_waterdata_combine_meta, and read_waterdata_channel +* Added read_ngwmn_water_levels, read_ngwmn_sites, read_ngwmn_providers, read_ngwmn_well_construction, read_ngwmn_lithology +* Removed readNWISgwl, readNWISmeas, and readNGWMN as services have been turned off +* Added data.table to Imports * Updated next_req_url to allow paging through /statistics API output * Added deprecation message to readNWISstat function -* Specify "UTC" attribute for returned time +* Improved time documentation for waterdata functions +* Specify "UTC" attribute for returned time for waterdata functinos * Added options("dataRetrieval.attach_request" = TRUE) as default to attach the request object as an attribute to the returned data frames. Setting options("dataRetrieval.attach_request" = FALSE) will return a data frame without the request attribute -* Improved time documentation * Improved error handling in WQP functions -* Added read_waterdata_field_meta, read_waterdata_combine_meta, -and read_waterdata_channel -* Removed readNWISgwl and readNWISmeas as services have been turned off * Updated CQL2 templates to allow HUC queries specifically to use a wildcard to get multiple inclusive HUCs. * Add deprecation message to readNGWMN functions. read_ngwmn will be coming soon. + dataRetrieval 2.7.22 =================== * Added read_waterdata_latest_daily to access latest daily USGS water data. diff --git a/R/AAA.R b/R/AAA.R index ac8fa3667..1cd88cada 100644 --- a/R/AAA.R +++ b/R/AAA.R @@ -3,7 +3,9 @@ pkg.env <- new.env() .onLoad <- function(libname, pkgname) { suppressMessages(setAccess("public")) pkg.env$local_sf <- requireNamespace("sf", quietly = TRUE) - options("dataRetrieval.nldi_base" = "https://api.water.usgs.gov/nldi/linked-data/") + options( + "dataRetrieval.nldi_base" = "https://api.water.usgs.gov/nldi/linked-data/" + ) options("dataRetrieval.api_version" = "v0") options("dataRetrieval.api_version_stat" = "v0") options("dataRetrieval.attach_request" = TRUE) @@ -21,6 +23,7 @@ pkg.env <- new.env() "latest-continuous", "field-measurements", "latest-daily", + "latest-field-measurements", "continuous", "field-measurements-metadata", "combined-metadata", @@ -78,6 +81,7 @@ pkg.env <- new.env() "time_zone_code" ) + num_cols <- c() pkg.env$api_endpoints <- services pkg.env$metadata <- collections } diff --git a/R/construct_api_requests.R b/R/construct_api_requests.R index 937f80b0f..a00d787ec 100644 --- a/R/construct_api_requests.R +++ b/R/construct_api_requests.R @@ -43,6 +43,7 @@ construct_api_requests <- function( output_id, ..., bbox = NA, + base = "OGC", convertType = getOption("dataRetrieval.convertType"), no_paging = getOption("dataRetrieval.no_paging"), chunk_size = getOption("dataRetrieval.site_chunk_size_data"), @@ -92,13 +93,7 @@ construct_api_requests <- function( } single_params <- c( - "datetime", - "last_modified", - "begin", - "end", - "time", - "begin_utc", - "end_utc", + time_periods, "limit", "skipGeometry" ) @@ -159,7 +154,7 @@ construct_api_requests <- function( format_type <- ifelse(isTRUE(no_paging), "csv", "json") - baseURL <- setup_api(service, format = format_type) + baseURL <- setup_api(service, format = format_type, base = base) baseURL <- explode_query(baseURL, POST = FALSE, get_list, multi = "comma") if (all(!is.na(bbox))) { @@ -235,6 +230,7 @@ construct_api_requests <- function( #' Setup the request for the OGC API requests #' #' @noRd +#' @param base Character OGC or NGWMN #' @return httr2 request #' @examplesIf is_dataRetrieval_user() #' @@ -242,9 +238,17 @@ construct_api_requests <- function( #' request <- dataRetrieval:::base_url() #' request #' } -base_url <- function() { - httr2::request("https://api.waterdata.usgs.gov/ogcapi/") |> - httr2::req_url_path_append(getOption("dataRetrieval.api_version")) +base_url <- function(base = "OGC") { + match.arg(base, c("OGC", "NGWMN")) + + if (base == "OGC") { + baseURL <- httr2::request("https://api.waterdata.usgs.gov/ogcapi/") |> + httr2::req_url_path_append(getOption("dataRetrieval.api_version")) + } else { + baseURL <- httr2::request( + "https://api.waterdata.usgs.gov/ngwmn/ogcapi/" + ) + } } #' Setup the request for a particular endpoint collection @@ -257,8 +261,8 @@ base_url <- function() { #' request <- dataRetrieval:::setup_api("daily") #' request #' } -setup_api <- function(service, format = "json") { - baseURL <- base_url() |> +setup_api <- function(service, format = "json", base = "OGC") { + baseURL <- base_url(base) |> httr2::req_url_path_append("collections") |> httr2::req_url_path_append(service, "items") |> basic_request(format = format) @@ -654,5 +658,7 @@ time_periods <- c( "begin", "end", "begin_utc", - "end_utc" + "end_utc", + "revision_created", + "revision_modified" ) diff --git a/R/dataRetrieval-package.R b/R/dataRetrieval-package.R index de5ae89e9..0f0d1da4d 100644 --- a/R/dataRetrieval-package.R +++ b/R/dataRetrieval-package.R @@ -208,14 +208,15 @@ NULL # "field-measurements", "latest-daily", # "continuous", "field-measurements-metadata", # "combined-metadata", "channel-measurements", "peaks") -# +# # property_list <- list() # for(service in services){ # property_list[[service]] <- dataRetrieval:::get_properties_for_docs(service) # } # # num_cols <- c("value", "contributing_drainage_area", "drainage_area", -# "altitude_accuracy", "well_construction_depth", +# #"altitude_accuracy", +# "well_construction_depth", # "hole_construction_depth", "channel_flow", "channel_width", # "channel_area", "channel_velocity", "channel_location_distance") # diff --git a/R/deal_with_empty.R b/R/deal_with_empty.R index 1170845b2..554624284 100644 --- a/R/deal_with_empty.R +++ b/R/deal_with_empty.R @@ -6,6 +6,7 @@ #' as "daily", "monitoring-locations", "time-series-metadata" #' @param skipGeometry A logical for whether to return geometry #' @param convertType A logical for whether to convert value to numeric +#' @param base character, either "OGC" or "NGWMN" depending on data. #' #' @return data.frame #' @noRd @@ -25,20 +26,23 @@ deal_with_empty <- function( service, skipGeometry, convertType, - no_paging = FALSE + no_paging = FALSE, + base = "OGC" ) { if (nrow(return_list) == 0) { if (all(is.na(properties))) { - schema <- check_OGC_requests(endpoint = service, type = "schema") + schema <- check_OGC_requests( + endpoint = service, + type = "schema", + base = base + ) properties <- names(schema$properties) } return_list <- data.frame(matrix(nrow = 0, ncol = length(properties))) return_list <- lapply(return_list, as.character) names(return_list) <- properties - single_params <- c("datetime", "last_modified", "begin", "end", "time") - - for (i in single_params) { + for (i in time_periods) { if (i %in% names(return_list)) { return_list[[i]] <- as.POSIXct(as.character(), origin = "1970-01-01") } diff --git a/R/get_monitoring_location_arguments.R b/R/get_monitoring_location_arguments.R new file mode 100644 index 000000000..57103f7e7 --- /dev/null +++ b/R/get_monitoring_location_arguments.R @@ -0,0 +1,203 @@ +#' Get Monitoring Location Arguments +#' +#' Many read_waterdata functions have a long list of arguments that can be used +#' to find sites that have data. Users can use this function as a reference +#' of possible arguments that can be used as input. +#' Additionally, this function is also used by other functions to check that +#' the user supplied parameters are available to their queries +#' +#' @param service Endpoint to check arguments against. Possible values are +#' "daily", "latest-continuous", "field-measurements", "latest-daily", +#' "latest-field-measurements", "continuous", "peaks". +#' @param agency_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$agency_code$description` +#' @param agency_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$agency_name$description` +#' @param monitoring_location_number `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$monitoring_location_number$description` +#' @param monitoring_location_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$monitoring_location_name$description` +#' @param district_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$district_code$description` +#' @param country_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$country_code$description` +#' @param country_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$country_name$description` +#' @param state_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$state_code$description` +#' @param state_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$state_name$description` +#' @param county_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$county_code$description` +#' @param county_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$county_name$description` +#' @param minor_civil_division_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$minor_civil_division_code$description` +#' @param site_type_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$site_type_code$description` +#' @param site_type `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$site_type$description` +#' @param hydrologic_unit_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$hydrologic_unit_code$description` +#' @param basin_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$basin_code$description` +#' @param altitude `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$altitude$description` +#' @param altitude_accuracy `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$altitude_accuracy$description` +#' @param altitude_method_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$altitude_method_code$description` +#' @param altitude_method_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$altitude_method_name$description` +#' @param vertical_datum `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$vertical_datum$description` +#' @param vertical_datum_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$vertical_datum_name$description` +#' @param horizontal_positional_accuracy_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$horizontal_positional_accuracy_code$description` +#' @param horizontal_positional_accuracy `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$agency_code$description` +#' @param horizontal_position_method_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$horizontal_position_method_code$description` +#' @param horizontal_position_method_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$horizontal_position_method_name$description` +#' @param original_horizontal_datum `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$original_horizontal_datum$description` +#' @param original_horizontal_datum_name `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$original_horizontal_datum_name$description` +#' @param drainage_area `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$drainage_area$description` +#' @param contributing_drainage_area `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$contributing_drainage_area$description` +#' @param time_zone_abbreviation `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$time_zone_abbreviation$description` +#' @param uses_daylight_savings `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$agency_code$description` +#' @param construction_date `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$construction_date$description` +#' @param aquifer_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$aquifer_code$description` +#' @param national_aquifer_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$national_aquifer_code$description` +#' @param aquifer_type_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$agency_code$description` +#' @param well_constructed_depth `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$well_constructed_depth$description` +#' @param hole_constructed_depth `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$hole_constructed_depth$description` +#' @param depth_source_code `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$depth_source_code$description` +#' @param data_gap_interval `r check_OGC_requests(endpoint = "daily", type = "queryables")$properties$data_gap_interval$description` +#' @param \dots Not used. Used to make sure the user isn't passing in arguments that aren't available. +#' @param check_arguments Logical. Used to decide if the arguments passed in are available or not. The +#' default is `FALSE`. Using `TRUE` will make two calls to the API, so if you are concerned +#' with minimizing API calls, keep this value as `FALSE`. If you are concerned with +#' making sure your calls are accepted by the service, set to `TRUE`. +#' @export +#' @examples +#' +#' get_monitoring_location_arguments(service = "daily", agency_name = "USGS") +#' get_monitoring_location_arguments(service = "field-measurements", +#' state_name = c("Ohio", "Wisconsin")) +get_monitoring_location_arguments <- function( + service = "daily", + agency_code = NA_character_, + agency_name = NA_character_, + monitoring_location_number = NA_character_, + monitoring_location_name = NA_character_, + district_code = NA_character_, + country_code = NA_character_, + country_name = NA_character_, + state_code = NA_character_, + state_name = NA_character_, + county_code = NA_character_, + county_name = NA_character_, + minor_civil_division_code = NA_character_, + site_type_code = NA_character_, + site_type = NA_character_, + hydrologic_unit_code = NA_character_, + basin_code = NA_character_, + altitude = NA_character_, + altitude_accuracy = NA_character_, + altitude_method_code = NA_character_, + altitude_method_name = NA_character_, + vertical_datum = NA_character_, + vertical_datum_name = NA_character_, + horizontal_positional_accuracy_code = NA_character_, + horizontal_positional_accuracy = NA_character_, + horizontal_position_method_code = NA_character_, + horizontal_position_method_name = NA_character_, + original_horizontal_datum = NA_character_, + original_horizontal_datum_name = NA_character_, + drainage_area = NA_character_, + contributing_drainage_area = NA_character_, + time_zone_abbreviation = NA_character_, + uses_daylight_savings = NA_character_, + construction_date = NA_character_, + aquifer_code = NA_character_, + national_aquifer_code = NA_character_, + aquifer_type_code = NA_character_, + well_constructed_depth = NA_character_, + hole_constructed_depth = NA_character_, + depth_source_code = NA_character_, + data_gap_interval = NA_character_, + ..., + check_arguments = FALSE +) { + # Make sure no one passes in an argument that's not suppose to be there + rlang::check_dots_empty() + service_with_extra_queries <- c( + "daily", + "latest-continuous", + "field-measurements", + "latest-daily", + "latest-field-measurements", + "continuous", + "peaks" + ) + match.arg(service, choices = service_with_extra_queries, several.ok = FALSE) + + args <- mget(names(formals())) + args[["..."]] <- NULL + args[["service"]] <- NULL + args[["check_arguments"]] <- NULL + + n_args <- names(args) + + lapply(n_args, function(x) { + check_character(args[[x]], x) + }) + + if (check_arguments) { + # think about if we want this as an option + # don't want to waste a lot of hits to the API if people are + # running into their token limits + properties <- dataRetrieval::get_ogc_params(service) + queryables <- check_OGC_requests(endpoint = service, type = "queryables") + non_returned <- queryables$properties[ + !names(queryables$properties) %in% names(properties) + ] + + args_not_available <- args[!names(args) %in% names(non_returned)] + if (length(args_not_available) > 0) { + message( + "The ", + service, + " service doesn't accept: ", + paste0(names(args_not_available), collapse = ", "), + "." + ) + message("Those arguments will be ignored.") + } + + args <- args[names(args) %in% names(non_returned)] + } + + return(args) +} + +cleanup_arguments <- function(args, monitoring_location_arguments, service) { + query_args <- do.call( + get_monitoring_location_arguments, + c(monitoring_location_arguments, service = service) + ) + + args[["monitoring_location_arguments"]] <- NULL + args[["..."]] <- NULL + args <- c(args, query_args) + + return(args) +} + +check_character <- function(x, name) { + if (!is.null(x)) { + if (all(!is.na(x) & !is.character(x))) { + stop(paste(name, "should be a character")) + } + } +} + +check_numeric <- function(x, name) { + if (!is.null(x)) { + if (all(!is.na(x) & !is.numeric(x))) { + stop(paste(name, "should be a numeric")) + } + } +} + +check_integer <- function(x, name) { + if (!is.null(x)) { + if (all(!is.na(x) & !is.numeric(x))) { + stop(paste(name, "should be a integer")) + } + } +} + +check_logical <- function(x, name) { + if (!is.null(x)) { + if (all(!is.na(x) & !is.logical(x))) { + stop(paste(name, "should be a logical (TRUE/FALSE)")) + } + } +} diff --git a/R/get_ogc_data.R b/R/get_ogc_data.R index d78519fd6..87be4141e 100644 --- a/R/get_ogc_data.R +++ b/R/get_ogc_data.R @@ -6,7 +6,7 @@ #' #' @noRd #' @return data.frame with attributes -get_ogc_data <- function(args, output_id, service) { +get_ogc_data <- function(args, output_id, service, base = "OGC") { chunk_size <- args[["chunk_size"]] args[["..."]] <- NULL @@ -20,7 +20,12 @@ get_ogc_data <- function(args, output_id, service) { rl <- lapply(ml_splits, function(x) { args[["monitoring_location_id"]] <- x - get_ogc_data(args = args, output_id = output_id, service = service) + get_ogc_data( + args = args, + output_id = output_id, + service = service, + base = base + ) }) rl_filtered <- rl[ @@ -35,6 +40,7 @@ get_ogc_data <- function(args, output_id, service) { } else { args[["output_id"]] <- output_id args[["service"]] <- service + args[["base"]] <- base req <- do.call(construct_api_requests, args) @@ -49,12 +55,13 @@ get_ogc_data <- function(args, output_id, service) { } return_list <- deal_with_empty( - return_list, - args[["properties"]], - service, - isTRUE(args[["skipGeometry"]]), - args[["convertType"]], - no_paging + return_list = return_list, + properties = args[["properties"]], + service = service, + skipGeometry = isTRUE(args[["skipGeometry"]]), + convertType = args[["convertType"]], + no_paging = no_paging, + base = base ) return_list <- rejigger_cols(return_list, args[["properties"]], output_id) @@ -211,46 +218,19 @@ switch_properties_id <- function(properties, id) { #' the default for time series functions is #' `r getOption("dataRetrieval.site_chunk_size_data")`. #' Setting to `NA` will eliminate site chunking, giving users full control. -#' @param \dots Not used. Included to help differentiate official Water Data API arguments -#' from more seldom used, optional dataRetrieval-specific arguments. #' @keywords internal check_arguments_non_api <- function( convertType, no_paging, limit, attach_request, - chunk_size, - ... + chunk_size ) { - if (!is.null(convertType)) { - if (!is.na(convertType) & !is.logical(convertType)) { - stop("convertType should be a logical TRUE/FALSE") - } - } - - if (!is.null(no_paging)) { - if (!is.na(no_paging) & !is.logical(no_paging)) { - stop("no_paging should be a logical TRUE/FALSE") - } - } - - if (!is.null(attach_request)) { - if (!is.na(attach_request) & !is.logical(attach_request)) { - stop("attach_request should be a logical TRUE/FALSE") - } - } - - if (!is.null(limit)) { - if (!is.na(limit) & !is.numeric(limit)) { - stop("limit should be an integer") - } - } - - if (!is.null(chunk_size)) { - if (!is.na(chunk_size) & !is.numeric(chunk_size)) { - stop("chunk_size should be an integer") - } - } + check_logical(convertType, "convertType") + check_logical(no_paging, "no_paging") + check_logical(attach_request, "attach_request") + check_integer(limit, "limit") + check_integer(chunk_size, "chunk_size") } #' Check other arguments @@ -270,11 +250,7 @@ check_arguments_non_api <- function( #' #' @keywords internal check_arguments_api <- function(bbox, skipGeometry) { - if (!is.null(skipGeometry)) { - if (!is.na(skipGeometry) & !is.logical(skipGeometry)) { - stop("skipGeometry should be a logical TRUE/FALSE") - } - } + check_logical(skipGeometry, "skipGeometry") if (!is.null(bbox)) { if (!all(is.na(bbox))) { diff --git a/R/get_ogc_documentation.R b/R/get_ogc_documentation.R index c4474f160..dc29866a3 100644 --- a/R/get_ogc_documentation.R +++ b/R/get_ogc_documentation.R @@ -3,6 +3,7 @@ #' This function populates the parameter descriptions. #' #' @param service Character, can be any of the endpoints +#' @param base Character, can be "OGC" or "NGWMN" #' @return list #' @noRd #' @examplesIf is_dataRetrieval_user() @@ -10,10 +11,13 @@ #' \donttest{ #' ml_desc <- dataRetrieval:::get_description("monitoring-locations") #' ml_desc +#' +#' wl_desc <- dataRetrieval:::get_description("waterLevelObs", base = "NGWMN") +#' wl_desc #' } #' -get_description <- function(service) { - query_ret <- get_collection() +get_description <- function(service, base = "OGC") { + query_ret <- get_collection(base) tags <- query_ret[["tags"]] @@ -36,8 +40,8 @@ get_description <- function(service) { #' collection #' } #' -get_collection <- function() { - check_collections <- base_url() |> +get_collection <- function(base = "OGC") { + check_collections <- base_url(base = base) |> httr2::req_url_path_append("openapi") |> httr2::req_url_query(f = "html#/server/getCollections") @@ -55,6 +59,7 @@ get_collection <- function() { #' available, it will also contain a description. #' #' @param service Character, can be any of the USGS Waterdata API endpoints or collections. +#' @param base Either "OGC" for waterdata, or "NGWMN" for National Groundwater Monitoring Network. #' @return list #' @export #' @examplesIf is_dataRetrieval_user() @@ -64,8 +69,8 @@ get_collection <- function() { #' ml$national_aquifer_code #' } #' -get_ogc_params <- function(service) { - check_queryables_req <- base_url() |> +get_ogc_params <- function(service, base = "OGC") { + check_queryables_req <- base_url(base) |> httr2::req_url_path_append("collections") |> httr2::req_url_path_append(service) |> httr2::req_url_path_append("schema") |> @@ -74,7 +79,13 @@ get_ogc_params <- function(service) { query_ret <- httr2::req_perform(check_queryables_req) |> httr2::resp_body_json() - params <- sapply(query_ret$properties, function(x) x[["description"]]) + if (base == "OGC") { + params <- sapply(query_ret$properties, function(x) x[["description"]]) + } else if (base == "NGWMN") { + params <- query_ret$properties + } + + params } @@ -85,6 +96,7 @@ get_ogc_params <- function(service) { #' #' @param service Character, can be any of the endpoints #' @param output_id Character, dataRetrieval output name +#' @param base Character, either "OGC" or "NGWMN" #' @return list #' @noRd #' @examplesIf is_dataRetrieval_user() @@ -93,10 +105,14 @@ get_ogc_params <- function(service) { #' dataRetrieval:::get_properties_for_docs("monitoring-locations", #' "monitoring_location_id") #' +#' dataRetrieval:::get_properties_for_docs("waterLevelObs", +#' base = "NGWMN") +#' #' } #' -get_properties_for_docs <- function(service, output_id = NA) { - schema <- check_OGC_requests(endpoint = service, type = "schema") +get_properties_for_docs <- function(service, output_id = NA, base = "OGC") { + schema <- check_OGC_requests(endpoint = service, type = "schema", base = base) + properties <- names(schema$properties) if (!is.na(output_id)) { properties[properties == "id"] <- output_id @@ -109,6 +125,7 @@ get_properties_for_docs <- function(service, output_id = NA) { #' #' @param endpoint Character, can be any existing collection #' @param type Character, can be "queryables", "schema" +#' @param base Character, can be "OGC" or "NGWMN" #' @export #' @keywords internal #' @return list @@ -124,13 +141,24 @@ get_properties_for_docs <- function(service, output_id = NA) { #' type = "queryables") #' ts_meta_schema <- check_OGC_requests(endpoint = "time-series-metadata", #' type = "schema") +#' +#' ngwml <- check_OGC_requests(endpoint = "waterLevelObs", +#' type = "schema", +#' base = "NGWMN") #' } -check_OGC_requests <- function(endpoint = "daily", type = "queryables") { +check_OGC_requests <- function( + endpoint = "daily", + type = "queryables", + base = "OGC" +) { match.arg(type, c("queryables", "schema")) + match.arg(base, c("OGC", "NGWMN")) - match.arg(endpoint, c(pkg.env$api_endpoints, pkg.env$metadata)) + if (base == "OGC") { + match.arg(endpoint, c(pkg.env$api_endpoints, pkg.env$metadata)) + } - req <- base_url() |> + req <- base_url(base) |> httr2::req_url_path_append("collections") |> httr2::req_url_path_append(endpoint) |> httr2::req_url_path_append(type) |> diff --git a/R/importNGWMN_wml2.R b/R/importNGWMN_wml2.R index f35d4bcae..0b2fcec1f 100644 --- a/R/importNGWMN_wml2.R +++ b/R/importNGWMN_wml2.R @@ -32,6 +32,13 @@ #' } #' importNGWMN <- function(input, asDateTime = FALSE, tz = "UTC") { + + .Deprecated( + new = "read_ngwmn_water_level", + package = "dataRetrieval", + msg = "Updated NGWMN APIs will use read_ngwmn set of functions." + ) + if (tz != "") { tz <- match.arg(tz, OlsonNames()) } else { diff --git a/R/readNGWMNdata.R b/R/readNGWMNdata.R deleted file mode 100644 index 5c01cecdf..000000000 --- a/R/readNGWMNdata.R +++ /dev/null @@ -1,277 +0,0 @@ -#' Import data from the National Groundwater Monitoring Network. -#' -#' Only water level data and site locations and names are currently available through the web service. -#' @param service char Service for the request - "observation" and "featureOfInterest" are implemented. -#' @param \dots Other parameters to supply, namely `siteNumbers` or `bbox` -#' @param asDateTime logical if `TRUE`, will convert times to POSIXct format. Currently defaults to -#' `FALSE` since time zone information is not included. -#' @param tz character to set timezone attribute of dateTime. Default is "UTC", and converts the -#' date times to UTC, properly accounting for daylight savings times based on the data's provided time zone offset. -#' Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", -#' "America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu", -#' "America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also `OlsonNames()` -#' for more information on time zones. -#' @export -#' @examplesIf is_dataRetrieval_user() -#' \donttest{ -#' # one site -#' site <- "USGS.430427089284901" -#' #oneSite <- readNGWMNdata(siteNumbers = site, service = "observation") -#' -#' # multiple sites -#' sites <- c("USGS.272838082142201", "USGS.404159100494601", "USGS.401216080362703") -#' # Very slow: -#' # multiSiteData <- readNGWMNdata(siteNumbers = sites, service = "observation") -#' # attributes(multiSiteData) -#' -#' # non-USGS site -#' # accepts colon or period between agency and ID -#' site <- "MBMG:702934" -#' # data <- readNGWMNdata(siteNumbers = site, service = "featureOfInterest") -#' -#' # bounding box -#' # bboxSites <- readNGWMNdata(service = "featureOfInterest", bbox = c(30, -102, 31, 99)) -#' # retrieve sites. Set asDateTime to false since one site has an invalid date -#' # Very slow: -#' # bboxData <- readNGWMNdata(service = "observation", siteNumbers = bboxSites$site[1:3], -#' # asDateTime = FALSE) -#' } -#' -readNGWMNdata <- function(service, ..., asDateTime = TRUE, tz = "UTC") { - .Deprecated( - "", - msg = "read_ngwmn_data coming soon. Check back at - https://doi-usgs.github.io/dataRetrieval/articles/Status.html - for more information" - ) - - dots <- convertLists(...) - - match.arg(service, c("observation", "featureOfInterest")) - - if (service == "observation") { - # these attributes are pulled out and saved when doing binds to be reattached - attrs <- c( - "url", - "gml:identifier", - "generationDate", - "responsibleParty", - "contact" - ) - featureID <- stats::na.omit(gsub(":", ".", dots[["siteNumbers"]])) - - obs_list <- vector("list", length(featureID)) - attr_list <- vector("list", length(featureID)) - for (idx in seq_along(featureID)) { - obsFID <- retrieveObservation( - featureID = featureID[idx], asDateTime, attrs, tz = tz - ) - attr_list[[idx]] <- saveAttrs(attrs, obsFID) - obs_list[[idx]] <- removeAttrs(attrs, obsFID) - } - allObs <- Reduce(r_bind_dr, obs_list, init = data.frame()) - allAttrs <- Reduce(r_bind_dr, attr_list, init = data.frame()) - - allSites <- tryCatch( - { - retrieveFeatureOfInterest(featureID = featureID) - }, - error = function(cond) { - return(NULL) - } - ) - - if (!is.null(allSites)) { - attr(allObs, "siteInfo") <- allSites - } - - attr(allObs, "other") <- allAttrs - returnData <- allObs - } else if (service == "featureOfInterest") { - if ("siteNumbers" %in% names(dots)) { - featureID <- stats::na.omit(gsub(":", ".", dots[["siteNumbers"]])) - allSites <- tryCatch({ - retrieveFeatureOfInterest(featureID = featureID) - }) - } - - if ("bbox" %in% names(dots)) { - allSites <- tryCatch({ - retrieveFeatureOfInterest(bbox = dots[["bbox"]]) - }) - } - returnData <- allSites - } - - return(returnData) -} - -#' Retrieve groundwater levels from the National Ground Water Monitoring Network. -#' -#' @param siteNumbers character Vector of feature IDs formatted with agency code and site number -#' separated by a period or semicolon, e.g. `USGS.404159100494601`. -#' @param asDateTime logical Should dates and times be converted to date/time objects, -#' or returned as character? Defaults to `TRUE`. Must be set to `FALSE` if a site -#' contains non-standard dates. -#' @param tz character to set timezone attribute of dateTime. Default is "UTC", and converts the -#' date times to UTC, properly accounting for daylight savings times based on the data's provided time zone offset. -#' Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", -#' "America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu", -#' "America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also `OlsonNames()` -#' for more information on time zones. -#' @export -#' -#' @examplesIf is_dataRetrieval_user() -#' \donttest{ -#' # one site -#' site <- "USGS.430427089284901" -#' # oneSite <- readNGWMNlevels(siteNumbers = site) -#' -#' # multiple sites -#' sites <- c("USGS:272838082142201", "USGS:404159100494601", "USGS:401216080362703") -#' # multiSiteData <- readNGWMNlevels(sites) -#' -#' # non-USGS site -#' site <- "MBMG.103306" -#' # data <- readNGWMNlevels(siteNumbers = site, asDateTime = FALSE) -#' -#' # site with no data returns empty data frame -#' noDataSite <- "UTGS.401544112060301" -#' # noDataSite <- readNGWMNlevels(siteNumbers = noDataSite) -#' } -readNGWMNlevels <- function(siteNumbers, asDateTime = TRUE, tz = "UTC") { - data <- readNGWMNdata( - siteNumbers = siteNumbers, - service = "observation", - asDateTime = asDateTime, - tz = tz - ) - return(data) -} - -#' Retrieve site data from the National Ground Water Monitoring Network. -#' -#' @param siteNumbers character Vector of feature IDs formatted with agency code and site number -#' separated by a period or semicolon, e.g. `USGS.404159100494601`. -#' -#' @export -#' @return A data frame the following columns: -#' #' \tabular{lll}{ -#' Name \tab Type \tab Description \cr -#' site \tab char \tab Site FID \cr -#' description \tab char \tab Site description \cr -#' dec_lat_va, dec_lon_va \tab numeric \tab Site latitude and longitude \cr -#' } -#' @examplesIf is_dataRetrieval_user() -#' \donttest{ -#' # one site -#' site <- "USGS.430427089284901" -#' #oneSite <- readNGWMNsites(siteNumbers = site) -#' -#' # non-USGS site -#' site <- "MBMG.103306" -#' #siteInfo <- readNGWMNsites(siteNumbers = site) -#' } -readNGWMNsites <- function(siteNumbers) { - sites <- readNGWMNdata( - siteNumbers = siteNumbers, - service = "featureOfInterest" - ) - return(sites) -} - -retrieveObservation <- function(featureID, asDateTime, attrs, tz) { - baseURL <- httr2::request(pkg.env[["NGWMN"]]) - baseURL <- httr2::req_url_query( - baseURL, - request = "GetObservation", - service = "SOS", - version = "2.0.0", - observedProperty = "urn:ogc:def:property:OGC:GroundWaterLevel", - responseFormat = "text/xml", - featureOfInterest = paste("VW_GWDP_GEOSERVER", featureID, sep = ".") - ) - - returnData <- importNGWMN(baseURL, asDateTime = asDateTime, tz = tz) - if (nrow(returnData) == 0) { - # need to add NA attributes, so they aren't messed up when stored as DFs - attr(returnData, "gml:identifier") <- NA - attr(returnData, "generationDate") <- NA - } - - # mutate removes the attributes, need to save and append - attribs <- saveAttrs(attrs, returnData) - if (nrow(returnData) > 0) { - # tack on site number - siteNum <- rep(sub(".*\\.", "", featureID), nrow(returnData)) - returnData$site <- siteNum - numCol <- ncol(returnData) - returnData <- returnData[, c(numCol, 1:(numCol - 1))] # move siteNum to the left - } - attributes(returnData) <- c(attributes(returnData), as.list(attribs)) - - return(returnData) -} - -# retrieve feature of interest -# could allow pass through srsName - needs to be worked in higher-up in dots -retrieveFeatureOfInterest <- function( - ..., - asDateTime, - srsName = "urn:ogc:def:crs:EPSG::4269" -) { - values <- convertLists(...) - - baseURL <- httr2::request(pkg.env[["NGWMN"]]) - baseURL <- httr2::req_url_query( - baseURL, - request = "GetFeatureOfInterest", - service = "SOS", - version = "2.0.0", - responseFormat = "text/xml" - ) - - if ("featureID" %in% names(values)) { - features <- paste("VW_GWDP_GEOSERVER", values[["featureID"]], sep = ".") - - baseURL <- httr2::req_url_query( - baseURL, - featureOfInterest = features, - .multi = "comma" - ) - } else if ("bbox" %in% names(values)) { - baseURL <- httr2::req_url_query( - baseURL, - bbox = paste(values[["bbox"]], collapse = ","), - srsName = srsName - ) - } else { - stop("Geographical filter not specified. Please use siteNumbers or bbox") - } - - siteDF <- importNGWMN(baseURL, asDateTime, tz = "") - attr(siteDF, "url") <- baseURL$url - attr(siteDF, "queryTime") <- Sys.time() - return(siteDF) -} - - -# save specified attributes from a data frame -saveAttrs <- function(attrs, df) { - attribs <- sapply(attrs, function(x) attr(df, x)) - if (is.vector(attribs)) { - toReturn <- as.data.frame(t(attribs), stringsAsFactors = FALSE) - } else { - # don't need to transpose - toReturn <- as.data.frame(attribs, stringsAsFactors = FALSE) - } - return(toReturn) -} - -# strip specified attributes from a data frame -removeAttrs <- function(attrs, df) { - for (a in attrs) { - attr(df, a) <- NULL - } - return(df) -} diff --git a/R/readNWISdata.R b/R/readNWISdata.R index 1e12c1df9..b50e03d2f 100644 --- a/R/readNWISdata.R +++ b/R/readNWISdata.R @@ -72,81 +72,6 @@ #' #' @seealso [read_waterdata()] #' @export -#' @examplesIf is_dataRetrieval_user() -#' \donttest{ -#' # Examples not run for time considerations -#' -#' instFlow <- readNWISdata( -#' sites = "05114000", service = "iv", -#' parameterCd = "00060", -#' startDate = "2014-05-01T00:00Z", endDate = "2014-05-01T12:00Z" -#' ) -#' -#' instFlowCDT <- readNWISdata( -#' sites = "05114000", service = "iv", -#' parameterCd = "00060", -#' startDate = "2014-05-01T00:00", endDate = "2014-05-01T12:00", -#' tz = "America/Chicago" -#' ) -#' -#' multiSite <- readNWISdata( -#' sites = c("04025500", "040263491"), -#' service = "iv", parameterCd = "00060" -#' ) -#' -#' waterYearStat <- readNWISdata( -#' site = c("01646500"), -#' service = "stat", -#' statReportType = "annual", -#' statYearType = "water", -#' missingData = "on" -#' ) -#' monthlyStat <- readNWISdata( -#' site = c("01646500"), -#' service = "stat", -#' statReportType = "monthly" -#' ) -#' -#' dailyStat <- readNWISdata( -#' site = c("01646500"), -#' service = "stat", -#' statReportType = "daily", -#' statType = c("p25", "p50", "p75", "min", "max"), -#' parameterCd = "00060" -#' ) -#' -#' arg.list <- list( -#' site = "03111548", -#' statReportType = "daily", -#' statType = c("p25", "p50", "p75", "min", "max"), -#' parameterCd = "00060" -#' ) -#' allDailyStats_2 <- readNWISdata(arg.list, service = "stat") -#' -#' -#' site_id <- "01594440" -#' rating_curve <- readNWISdata(service = "rating", site_no = site_id, file_type = "base") -#' all_sites_base <- readNWISdata(service = "rating", file_type = "base") -#' all_sites_core <- readNWISdata(service = "rating", file_type = "corr") -#' all_sites_exsa <- readNWISdata(service = "rating", file_type = "exsa") -#' all_sites_24hrs <- readNWISdata(service = "rating", file_type = "exsa", period = 24) -#' -#' peak_data <- readNWISdata( -#' service = "peak", -#' site_no = c("01594440", "040851325"), -#' range_selection = "data_range" -#' ) -#' -#' peak_data <- readNWISdata( -#' service = "peak", -#' state_cd = "PA" -#' ) -#' -#' peak_data <- readNWISdata( -#' service = "peak", -#' huc2_cd = "20" -#' ) -#' } readNWISdata <- function( ..., asDateTime = TRUE, diff --git a/R/readNWISunit.R b/R/readNWISunit.R index fd6f5c88c..515054de8 100644 --- a/R/readNWISunit.R +++ b/R/readNWISunit.R @@ -463,9 +463,8 @@ readNWISuse <- function( transform = FALSE ) { .Deprecated( - new = "read_waterdata_use_data in development", package = "dataRetrieval", - msg = "NWIS servers for water use have been decommission. New functions are being developed." + msg = "NWIS servers for water use have been decommissioned. New functions are being developed." ) return(NULL) } diff --git a/R/read_ngwmn.R b/R/read_ngwmn.R new file mode 100644 index 000000000..f1b9fca6b --- /dev/null +++ b/R/read_ngwmn.R @@ -0,0 +1,143 @@ +#' Generalized NGWMN API retrieval function +#' +#' Function that allows complex CQL queries on National Groundwater +#' Monitoring Network API. +#' See +#' for more information. +#' +#' @export +#' @param service character, can be any existing collection. Can be: +#' "providers", "constructionObs", "waterLevelObs", "sites", or "lithologyObs". +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$sample_time$description` +#' See also Details below for more information. +#' @param CQL A string in a Common Query Language format. +#' @param monitoring_location_id `r get_ogc_params("waterLevelObs", base = "NGWMN")$monitoring_location_id$description` +#' @param convertType logical, defaults to `TRUE`. If `TRUE`, the function +#' will convert the data to dates and qualifier to string vector. +#' @param \dots Additional arguments to send to the request. +#' @inheritParams check_arguments_non_api +#' +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' cql <- '{ +#' "op": "between", +#' "args": [ +#' { "property": "water_level_above_navd88_ft" }, +#' [ "100.00", "200.00" ] +#' ] +#' }' +#' +#' wl_data <- read_ngwmn(service = "waterLevelObs", +#' monitoring_location_id = c("USGS-272838082142201", +#' "USGS-404159100494601", +#' "USGS-401216080362703"), +#' CQL = cql) +#' +#'cql3 <- '{ +#' "op": "and", +#' "args": [ +#' { +#' "op": "between", +#' "args": [ +#' { "property": "water_level_above_navd88_ft" }, +#' [ "100.00", "200.00" ] +#' ] +#' }, +#' { +#' "op": "in", +#' "args": [ +#' { "property": "monitoring_location_id" }, +#' [ "USGS-272838082142201", "USGS-404159100494601", "USGS-401216080362703" ] +#' ] +#' } +#'] +#'}' +#' +#' +#' wl_data_alt <- read_ngwmn(service = "waterLevelObs", +#' CQL = cql3) +#' +#' } +read_ngwmn <- function( + service, + CQL = NA_character_, + monitoring_location_id = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) { + match.arg(service, c("providers", "constructionObs", + "waterLevelObs", "sites", + "lithologyObs")) + + args <- list(...) + args[["monitoring_location_id"]] <- monitoring_location_id + + if(service %in% c("lithologyObs", "waterLevelObs", "constructionObs")){ + # Mandatory monitoring_location_ids + if(all(is.na(monitoring_location_id))){ + args[["monitoring_location_id"]] <- "ALL" + } + } else { + if(is.na(monitoring_location_id)){ + args[["monitoring_location_id"]] <- NULL + } + } + + args[["convertType"]] <- convertType + args[["limit"]] <- limit + args[["attach_request"]] <- attach_request + args[["bbox"]] <- NA + args[["no_paging"]] <- FALSE # drops id if TRUE + args[["chunk_size"]] <- NA # Chunking doesn't make sense. + + if (!"properties" %in% names(args)) { + args[["properties"]] <- NA_character_ + } + + args[["output_id"]] <- "id" + args[["base"]] <- "NGWMN" + args[["service"]] <- service + + data_req <- suppressWarnings(do.call(construct_api_requests, args)) + + if(isTRUE(!is.na(CQL) | CQL == "")){ + data_req <- data_req |> + httr2::req_headers(`Content-Type` = "application/query-cql-json") |> + httr2::req_body_raw(CQL) + } + + message("Requesting:\n", data_req$url) + + return_list <- walk_pages(data_req) + + return_list <- deal_with_empty(return_list = return_list, + properties = args[["properties"]], + service = service, + skipGeometry = isTRUE(args[["skipGeometry"]]), + convertType = args[["convertType"]], + no_paging = FALSE, + base = "NGWMN" + ) + + return_list <- rejigger_cols( + return_list, + args[["properties"]], + args[["output_id"]] + ) + + if (convertType) { + return_list <- cleanup_cols(return_list, service) + return_list <- order_results(return_list) + return_list <- move_id_col(return_list, args[["output_id"]]) + } + + if (args[["attach_request"]]) { + attr(return_list, "request") <- data_req + } + attr(return_list, "queryTime") <- Sys.time() + + return(return_list) +} diff --git a/R/read_ngwmn_lithology.R b/R/read_ngwmn_lithology.R new file mode 100644 index 000000000..d4092fd3f --- /dev/null +++ b/R/read_ngwmn_lithology.R @@ -0,0 +1,60 @@ +#' Get NGWMN Lithology Observations +#' +#' @description `r get_description("lithologyObs", base = "NGWMN")` +#' +#' @export +#' @param monitoring_location_id +#' `r get_ogc_params("lithologyObs", base = "NGWMN")$monitoring_location_id$description` +#' @param monitoring_location_obs_number +#' `r get_ogc_params("lithologyObs", base = "NGWMN")$monitoring_location_obs_number$description` +#' @param properties A vector of requested columns to be returned from the query. +#' Available options are: +#' `r dataRetrieval:::get_properties_for_docs("lithologyObs", base = "NGWMN")`. +#' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official NGWMN API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. +#' @inheritParams check_arguments_non_api +#' +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' site <- "AKDNR-535134236016630" +#' ngwmn_lith <- read_ngwmn_lithology(monitoring_location_id = site) +#' +#' +#' sites <- c("ISWS-P428197", +#' "AKDNR-535143966816631", +#' "AKDNR-535134236016630") +#' ngwml_lith_sites <- read_ngwmn_lithology(monitoring_location_id = sites) +#' +#' } +read_ngwmn_lithology <- function( + monitoring_location_id = NA_character_, + monitoring_location_obs_number = NA_character_, + properties = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) { + service <- "lithologyObs" + + # Check for mandatory arguments: + if (all(is.na(monitoring_location_id))) { + stop("monitoring_location_id is a mandatory argument.") + } + + rlang::check_dots_empty() + args <- mget(names(formals())) + + return_list <- get_ogc_data( + args = args, + output_id = "id", + service = service, + base = "NGWMN" + ) + + return(return_list) +} diff --git a/R/read_ngwmn_providers.R b/R/read_ngwmn_providers.R new file mode 100644 index 000000000..d3740e600 --- /dev/null +++ b/R/read_ngwmn_providers.R @@ -0,0 +1,57 @@ +#' Get NGWMN Provider Data +#' +#' @description `r get_description("providers", base = "NGWMN")` +#' +#' @export +#' @param state +#' `r get_ogc_params("providers", base = "NGWMN")$state$description` +#' @param agency_code +#' `r get_ogc_params("providers", base = "NGWMN")$agency_code$description` +#' @param organization_type +#' `r get_ogc_params("providers", base = "NGWMN")$organization_type$description` +#' @param properties A vector of requested columns to be returned from the query. +#' Available options are: +#' `r dataRetrieval:::get_properties_for_docs("providers", base = "NGWMN")`. +#' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official NGWMN API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. +#' @inheritParams check_arguments_non_api +#' +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' +#' ngwmn_providers <- read_ngwmn_providers(state = "WI") +#' +#' ngwml_providers2 <- read_ngwmn_providers(state = c("WI", "CA", "AZ", "MN")) +#' +#' org_type <- read_ngwmn_providers(organization_type = "NWIS", state = c("WI", "MN")) +#' +#' } +read_ngwmn_providers <- function( + state = NA_character_, + agency_code = NA_character_, + organization_type = NA_character_, + properties = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) { + service <- "providers" + rlang::check_dots_empty() + args <- mget(names(formals())) + + return_list <- get_ogc_data( + args = args, + output_id = "id", + service = service, + base = "NGWMN" + ) + + return_list <- sf::st_drop_geometry(return_list) + + return(return_list) +} diff --git a/R/read_ngwmn_sites.R b/R/read_ngwmn_sites.R new file mode 100644 index 000000000..961900a44 --- /dev/null +++ b/R/read_ngwmn_sites.R @@ -0,0 +1,132 @@ +#' Get NGWMN Site Data +#' +#' @description `r get_description("sites", base = "NGWMN")` +#' +#' @export +#' @param monitoring_location_id +#' `r get_ogc_params("sites", base = "NGWMN")$monitoring_location_id$description` +#' @param agency_code +#' `r get_ogc_params("sites", base = "NGWMN")$agency_code$description` +#' @param monitoring_location_number +#' `r get_ogc_params("sites", base = "NGWMN")$monitoring_location_number$description` +#' @param altitude +#' `r get_ogc_params("sites", base = "NGWMN")$altitude$description` +#' @param national_aquifer_code +#' `r get_ogc_params("sites", base = "NGWMN")$national_aquifer_code$description` +#' @param national_aquifer_description +#' `r get_ogc_params("sites", base = "NGWMN")$national_aquifer_description$description` +#' @param country_code +#' `r get_ogc_params("sites", base = "NGWMN")$country_code$description` +#' @param country_name +#' `r get_ogc_params("sites", base = "NGWMN")$country_name$description` +#' @param state_name +#' `r get_ogc_params("sites", base = "NGWMN")$state_name$description` +#' @param county_name +#' `r get_ogc_params("sites", base = "NGWMN")$county_name$description` +#' @param aquifer_name +#' `r get_ogc_params("sites", base = "NGWMN")$aquifer_name$description` +#' @param site_type +#' `r get_ogc_params("sites", base = "NGWMN")$site_type$description` +#' @param aquifer_type_code +#' `r get_ogc_params("sites", base = "NGWMN")$aquifer_type_code$description` +#' @param qw_sys_name +#' `r get_ogc_params("sites", base = "NGWMN")$qw_sys_name$description` +#' @param qw_sn_flag +#' `r get_ogc_params("sites", base = "NGWMN")$qw_sn_flag$description` +#' @param qw_baseline_flag +#' `r get_ogc_params("sites", base = "NGWMN")$qw_baseline_flag$description` +#' @param qw_well_chars +#' `r get_ogc_params("sites", base = "NGWMN")$qw_well_chars$description` +#' @param qw_well_type +#' `r get_ogc_params("sites", base = "NGWMN")$qw_well_type$description` +#' @param qw_well_purpose +#' `r get_ogc_params("sites", base = "NGWMN")$qw_well_purpose$description` +#' @param wl_sys_name +#' `r get_ogc_params("sites", base = "NGWMN")$wl_sys_name$description` +#' @param wl_sn_flag +#' `r get_ogc_params("sites", base = "NGWMN")$wl_sn_flag$description` +#' @param wl_baseline_flag +#' `r get_ogc_params("sites", base = "NGWMN")$wl_baseline_flag$description` +#' @param wl_well_chars +#' `r get_ogc_params("sites", base = "NGWMN")$wl_well_chars$description` +#' @param wl_well_type +#' `r get_ogc_params("sites", base = "NGWMN")$wl_well_type$description` +#' @param wl_well_purpose +#' `r get_ogc_params("sites", base = "NGWMN")$wl_well_purpose$description` +#' +#' @param properties A vector of requested columns to be returned from the query. +#' Available options are: +#' `r dataRetrieval:::get_properties_for_docs("sites", base = "NGWMN")`. +#' The default (`NA`) will return all columns of the data. +#' @param skipGeometry This option can be used to skip response geometries for +#' each feature. The returning object will be a data frame with no spatial +#' information. + +#' @param bbox Only features that have a geometry that intersects the bounding +#' box are selected.The bounding box is provided as four or six numbers, depending +#' on whether the coordinate reference system includes a vertical axis (height or +#' depth). Coordinates are assumed to be in crs 4326. The expected format is a numeric +#' vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, +#' Southern-most latitude, Eastern-most longitude, Northern-most longitude). +#' @param \dots Not used. Included to help differentiate official NGWMN API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. +#' @inheritParams check_arguments_non_api +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' +#' ngwmn_sites <- read_ngwmn_sites(state_name = "Minnesota") +#' +#' org_type <- read_ngwmn_sites(agency_code = "MN_DNR", +#' county_name = "Washington County") +#' +#' } +read_ngwmn_sites <- function( + monitoring_location_id = NA_character_, + agency_code = NA_character_, + monitoring_location_number = NA_character_, + altitude = NA_character_, + national_aquifer_code = NA_character_, + national_aquifer_description = NA_character_, + country_code = NA_character_, + country_name = NA_character_, + state_name = NA_character_, + county_name = NA_character_, + aquifer_name = NA_character_, + site_type = NA_character_, + aquifer_type_code = NA_character_, + qw_sys_name = NA_character_, + qw_sn_flag = NA_character_, + qw_baseline_flag = NA_character_, + qw_well_chars = NA_character_, + qw_well_type = NA_character_, + qw_well_purpose = NA_character_, + wl_sys_name = NA_character_, + wl_sn_flag = NA_character_, + wl_baseline_flag = NA_character_, + wl_well_chars = NA_character_, + wl_well_type = NA_character_, + wl_well_purpose = NA_character_, + bbox = NA, + properties = NA_character_, + skipGeometry = FALSE, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) { + service <- "sites" + rlang::check_dots_empty() + args <- mget(names(formals())) + + return_list <- get_ogc_data( + args = args, + output_id = "id", + service = service, + base = "NGWMN" + ) + + return(return_list) +} diff --git a/R/read_ngwmn_water_level.R b/R/read_ngwmn_water_level.R new file mode 100644 index 000000000..6bfc37784 --- /dev/null +++ b/R/read_ngwmn_water_level.R @@ -0,0 +1,89 @@ +#' Get NGWMN Water Level Data +#' +#' @description `r dataRetrieval:::get_description("waterLevelObs", base = "NGWMN")` +#' +#' @export +#' @param monitoring_location_id +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$monitoring_location_id$description` +#' @param monitoring_location_obs_number +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$monitoring_location_obs_number$description` +#' @param sample_time +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$sample_time$description` +#' See also Details below for more information. +#' +#' @param data_provided_by +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$data_provided_by$description` +#' @param water_depth_below_land_surface_ft +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$water_depth_below_land_surface_ft$description` +#' @param water_level_above_site_datum_ft +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$water_level_above_site_datum_ft$description` +#' @param monitoring_location_vertical_datum +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$monitoring_location_vertical_datum$description` +#' @param water_level_above_navd88_ft +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$water_level_above_navd88_ft$description` +#' +#' @param datetime +#' `r get_ogc_params("waterLevelObs", base = "NGWMN")$sample_time$description` +#' +#' @param properties A vector of requested columns to be returned from the query. +#' Available options are: +#' `r dataRetrieval:::get_properties_for_docs("waterLevelObs", base = "NGWMN")`. +#' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official NGWMN API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. +#' @inheritParams check_arguments_non_api +#' +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' site <- "USGS-272838082142201" +#' ngwmn_wl <- read_ngwmn_water_level(monitoring_location_id = site) +#' +#' ngwmn_wl_sub <- read_ngwmn_water_level(monitoring_location_id = site, +#' monitoring_location_obs_number = 1:5) +#' +#' ngwml_wl_time2 <- read_ngwmn_water_level(monitoring_location_id = site, +#' datetime = c("2022-01-01", "2024-01-01")) +#' +#' sites <- c("USGS-272838082142201", "USGS-404159100494601", +#' "USGS-401216080362703", "MBMG-702934") +#' ngwml_wl_sites <- read_ngwmn_water_level(monitoring_location_id = sites) +#' +#' } +read_ngwmn_water_level <- function( + monitoring_location_id = NA_character_, + monitoring_location_obs_number = NA_character_, + sample_time = NA_character_, + data_provided_by = NA_character_, + water_depth_below_land_surface_ft = NA_character_, + water_level_above_site_datum_ft = NA_character_, + monitoring_location_vertical_datum = NA_character_, + water_level_above_navd88_ft = NA_character_, + properties = NA_character_, + datetime = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) { + service <- "waterLevelObs" + + # Check for mandatory arguments: + if (all(is.na(monitoring_location_id))) { + stop("monitoring_location_id is a mandatory argument.") + } + + rlang::check_dots_empty() + args <- mget(names(formals())) + + return_list <- get_ogc_data( + args = args, + output_id = "id", + service = service, + base = "NGWMN" + ) + + return(return_list) +} diff --git a/R/read_ngwmn_well_construction.R b/R/read_ngwmn_well_construction.R new file mode 100644 index 000000000..3caa5a3ab --- /dev/null +++ b/R/read_ngwmn_well_construction.R @@ -0,0 +1,63 @@ +#' Get NGWMN Well Construction Data +#' +#' @description `r get_description("constructionObs", base = "NGWMN")` +#' +#' @export +#' @param monitoring_location_id +#' `r get_ogc_params("constructionObs", base = "NGWMN")$monitoring_location_id$description` +#' @param monitoring_location_obs_number +#' `r get_ogc_params("constructionObs", base = "NGWMN")$monitoring_location_obs_number$description` +#' @param material +#' `r get_ogc_params("constructionObs", base = "NGWMN")$material$description` +#' @param properties A vector of requested columns to be returned from the query. +#' Available options are: +#' `r dataRetrieval:::get_properties_for_docs("constructionObs", base = "NGWMN")`. +#' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official NGWMN API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. +#' @inheritParams check_arguments_non_api +#' +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' site <- "USGS-272838082142201" +#' ngwmn_well <- read_ngwmn_well_construction(monitoring_location_id = site) +#' +#' ngwmn_well_sub <- read_ngwmn_well_construction(monitoring_location_id = site, +#' monitoring_location_obs_number = 2) +#' +#' sites <- c("USGS-272838082142201", "USGS-404159100494601", +#' "USGS-401216080362703", "MBMG-702934") +#' ngwml_well_sites <- read_ngwmn_well_construction(monitoring_location_id = sites) +#' +#' } +read_ngwmn_well_construction <- function( + monitoring_location_id = NA_character_, + monitoring_location_obs_number = NA_character_, + material = NA_character_, + properties = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) { + service <- "constructionObs" + # Check for mandatory arguments: + if (all(is.na(monitoring_location_id))) { + stop("monitoring_location_id is a mandatory argument.") + } + + rlang::check_dots_empty() + args <- mget(names(formals())) + + return_list <- get_ogc_data( + args = args, + output_id = "id", + service = service, + base = "NGWMN" + ) + + return(return_list) +} diff --git a/R/read_waterdata_channel.R b/R/read_waterdata_channel.R index 74e92840c..74fbdb9d1 100644 --- a/R/read_waterdata_channel.R +++ b/R/read_waterdata_channel.R @@ -34,6 +34,8 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("channel-measurements", "channel_measurements_id")`. #' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official Water Data API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api #' diff --git a/R/read_waterdata_combined_meta.R b/R/read_waterdata_combined_meta.R index de173e1db..b84e76b8a 100644 --- a/R/read_waterdata_combined_meta.R +++ b/R/read_waterdata_combined_meta.R @@ -82,6 +82,8 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("combined-metadata", "field_measurement_id")`. #' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official Water Data API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api #' @inherit read_waterdata_continuous details diff --git a/R/read_waterdata_continuous.R b/R/read_waterdata_continuous.R index d9291e560..def389673 100644 --- a/R/read_waterdata_continuous.R +++ b/R/read_waterdata_continuous.R @@ -6,9 +6,8 @@ #' 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. +#' in 2027. #' -#' Geometry output is not supported in the continuous data API endpoint. #' #' @export #' @param monitoring_location_id `r get_ogc_params("continuous")$monitoring_location_id` @@ -32,9 +31,13 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("continuous", "continuous_id")`. #' The default (`NA`) will return all columns of the data. -#' @param \dots Not used. Included to help differentiate official Water Data API arguments -#' from more seldom used, optional dataRetrieval-specific arguments. +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. +#' @seealso [get_monitoring_location_arguments()] #' @inheritParams check_arguments_non_api +#' @inheritParams check_arguments_api #' #' @details #' You can also use a vector of length 2 for any time queries (such as time @@ -76,6 +79,12 @@ #' parameter_code = c("00060", "72019"), #' last_modified = "P7D") #' +#' dane <- read_waterdata_continuous( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' parameter_code = "00060", +#' time = "P1D") +#' #' # how to split up request into roughly 3 year chunks #' #' site <- "USGS-0208458892" @@ -120,6 +129,8 @@ read_waterdata_continuous <- function( value = NA, last_modified = NA_character_, time = NA_character_, + skipGeometry = TRUE, + bbox = NA, ..., convertType = getOption("dataRetrieval.convertType"), limit = getOption("dataRetrieval.limit"), @@ -129,10 +140,14 @@ read_waterdata_continuous <- function( ) { service <- "continuous" output_id <- "continuous_id" - rlang::check_dots_empty() args <- mget(names(formals())) - args[["skipGeometry"]] <- TRUE + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) return_list <- get_ogc_data(args, output_id, service) diff --git a/R/read_waterdata_daily.R b/R/read_waterdata_daily.R index d13072c8f..7cd8e810f 100644 --- a/R/read_waterdata_daily.R +++ b/R/read_waterdata_daily.R @@ -25,10 +25,13 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("daily", "daily_id")`. #' The default (`NA`) will return all columns of the data. -#' +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api -#' +#' @seealso [get_monitoring_location_arguments()] #' @inherit read_waterdata_continuous details #' #' @examplesIf is_dataRetrieval_user() @@ -73,6 +76,13 @@ #' dv_data_no_request <- read_waterdata_daily(monitoring_location_id = site, #' parameter_code = "00060", #' time = c("2021-01-01", "2022-01-01")) +#' +#' dv_dane <- read_waterdata_daily( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' parameter_code = "00060", +#' time = "P7D") +#' #' } read_waterdata_daily <- function( monitoring_location_id = NA_character_, @@ -97,10 +107,16 @@ read_waterdata_daily <- function( ) { service <- "daily" output_id <- "daily_id" - rlang::check_dots_empty() args <- mget(names(formals())) - return_list <- get_ogc_data(args, output_id, service) + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) + + return_list <- get_ogc_data(args, output_id, service, base = "OGC") return(return_list) } diff --git a/R/read_waterdata_field_measurements.R b/R/read_waterdata_field_measurements.R index 25d822569..166da199c 100644 --- a/R/read_waterdata_field_measurements.R +++ b/R/read_waterdata_field_measurements.R @@ -37,8 +37,13 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("field-measurements", "field_measurement_id")`. #' The default (`NA`) will return all columns of the data. +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api +#' @seealso [get_monitoring_location_arguments()] #' #' @inherit read_waterdata_continuous details #' @@ -81,6 +86,12 @@ #' time = "2024-07-01T00:00:00Z/..", #' parameter_code = "00060") #' +#' dane <- read_waterdata_field_measurements( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' parameter_code = "00060", +#' time = "P30D") +#' #' #' } read_waterdata_field_measurements <- function( @@ -112,9 +123,15 @@ read_waterdata_field_measurements <- function( ) { service <- "field-measurements" output_id <- "field_measurement_id" - rlang::check_dots_empty() args <- mget(names(formals())) + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) + return_list <- get_ogc_data(args, output_id, service) return(return_list) diff --git a/R/read_waterdata_field_meta.R b/R/read_waterdata_field_meta.R index b45df0154..b499c5fbb 100644 --- a/R/read_waterdata_field_meta.R +++ b/R/read_waterdata_field_meta.R @@ -24,6 +24,8 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("field-measurements-metadata", "field_measurement_id")`. #' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official Water Data API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. #' #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api diff --git a/R/read_waterdata_latest_continuous.R b/R/read_waterdata_latest_continuous.R index e450561ae..f37ddb924 100644 --- a/R/read_waterdata_latest_continuous.R +++ b/R/read_waterdata_latest_continuous.R @@ -23,8 +23,13 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("latest-continuous", "latest_continuous_id")`. #' The default (`NA`) will return all columns of the data. +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api +#' @seealso [get_monitoring_location_arguments()] #' #' @inherit read_waterdata_continuous details #' @examplesIf is_dataRetrieval_user() @@ -60,6 +65,12 @@ #' parameter_code = c("00060", "72019"), #' last_modified = "P7D") #' +#' dane <- read_waterdata_latest_continuous( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' parameter_code = "00060", +#' time = "P1D") +#' #' } read_waterdata_latest_continuous <- function( monitoring_location_id = NA_character_, @@ -83,9 +94,15 @@ read_waterdata_latest_continuous <- function( ) { service <- "latest-continuous" output_id <- "latest_continuous_id" - rlang::check_dots_empty() args <- mget(names(formals())) + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) + return_list <- get_ogc_data(args, output_id, service) return(return_list) diff --git a/R/read_waterdata_latest_daily.R b/R/read_waterdata_latest_daily.R index 85bc6c11f..aa415f6e6 100644 --- a/R/read_waterdata_latest_daily.R +++ b/R/read_waterdata_latest_daily.R @@ -25,9 +25,13 @@ #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("latest-daily", "latest_daily_id")`. #' The default (`NA`) will return all columns of the data. -#' +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api +#' @seealso [get_monitoring_location_arguments()] #' @inherit read_waterdata_continuous details #' #' @examplesIf is_dataRetrieval_user() @@ -56,6 +60,12 @@ #' "USGS-01645000"), #' parameter_code = c("00060", "00010")) #' +#' dane <- read_waterdata_latest_daily( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' parameter_code = "00060", +#' time = "P7D") +#' #' } read_waterdata_latest_daily <- function( monitoring_location_id = NA_character_, @@ -80,9 +90,15 @@ read_waterdata_latest_daily <- function( ) { service <- "latest-daily" output_id <- "latest_daily_id" - rlang::check_dots_empty() args <- mget(names(formals())) + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) + return_list <- get_ogc_data(args, output_id, service) return(return_list) diff --git a/R/read_waterdata_latest_field.R b/R/read_waterdata_latest_field.R new file mode 100644 index 000000000..6f25d631d --- /dev/null +++ b/R/read_waterdata_latest_field.R @@ -0,0 +1,96 @@ +#' Get Latest USGS Field Measurement Data +#' +#' @description `r get_description("latest-field-measurements")` +#' +#' @export +#' @param monitoring_location_id `r get_ogc_params("latest-field-measurements")$monitoring_location_id` +#' Multiple monitoring_location_ids can be requested as a character vector. +#' @param parameter_code `r get_ogc_params("latest-field-measurements")$parameter_code` +#' Multiple parameter_codes can be requested as a character vector. +#' @param statistic_id `r get_ogc_params("latest-field-measurements")$statistic_id` +#' Multiple statistic_ids can be requested as a character vector. +#' @param time `r get_ogc_params("latest-field-measurements")$time` +#' +#' See also Details below for more information. +#' @param value `r get_ogc_params("latest-field-measurements")$value` +#' @param unit_of_measure `r get_ogc_params("latest-field-measurements")$unit_of_measure` +#' @param approval_status `r get_ogc_params("latest-field-measurements")$approval_status` +#' @param last_modified `r get_ogc_params("latest-field-measurements")$last_modified` +#' +#' See also Details below for more information. +#' @param time_series_id `r get_ogc_params("latest-field-measurements")$time_series_id` +#' Multiple time_series_ids can be requested as a character vector. +#' @param qualifier `r get_ogc_params("latest-field-measurements")$qualifier` +#' @param properties A vector of requested columns to be returned from the query. +#' Available options are: +#' `r dataRetrieval:::get_properties_for_docs("latest-field-measurements", "latest_field_id")`. +#' The default (`NA`) will return all columns of the data. +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. +#' @inheritParams check_arguments_api +#' @inheritParams check_arguments_non_api +#' @seealso [get_monitoring_location_arguments()] +#' @inherit read_waterdata_continuous details +#' +#' @examplesIf is_dataRetrieval_user() +#' +#' \donttest{ +#' site <- "USGS-01435000" +#' +#' field_data_sf <- read_waterdata_latest_field_measurements(monitoring_location_id = site) +#' +#' dv_data_trim <- read_waterdata_latest_field_measurements(monitoring_location_id = site, +#' properties = c("monitoring_location_id", +#' "value", +#' "time")) +#' +#' field_data <- read_waterdata_latest_field_measurements(monitoring_location_id = site, +#' skipGeometry = TRUE) +#' +#' multi_site <- read_waterdata_latest_field_measurements(monitoring_location_id = c("USGS-01435000", +#' "USGS-14202650")) +#' +#' dane <- read_waterdata_latest_field_measurements( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' time = "P30D") +#' +#' } +read_waterdata_latest_field_measurements <- function( + monitoring_location_id = NA_character_, + parameter_code = NA_character_, + statistic_id = NA_character_, + properties = NA_character_, + time_series_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, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + limit = getOption("dataRetrieval.limit"), + chunk_size = getOption("dataRetrieval.site_chunk_size_meta"), + attach_request = getOption("dataRetrieval.attach_request") +) { + service <- "latest-field-measurements" + output_id <- "latest_field_id" + + args <- mget(names(formals())) + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) + + return_list <- get_ogc_data(args, output_id, service) + + return(return_list) +} diff --git a/R/read_waterdata_monitoring_location.R b/R/read_waterdata_monitoring_location.R index 8561f98a8..898f891cb 100644 --- a/R/read_waterdata_monitoring_location.R +++ b/R/read_waterdata_monitoring_location.R @@ -44,10 +44,27 @@ #' @param well_constructed_depth `r get_ogc_params("monitoring-locations")$well_constructed_depth` #' @param hole_constructed_depth `r get_ogc_params("monitoring-locations")$hole_constructed_depth` #' @param depth_source_code `r get_ogc_params("monitoring-locations")$depth_source_code` +#' @param revision_note `r get_ogc_params("monitoring-locations")$revision_note` +#' @param revision_created `r get_ogc_params("monitoring-locations")$revision_created` +#' @param revision_modified `r get_ogc_params("monitoring-locations")$revision_modified` #' @param properties A vector of requested columns to be returned from the query. #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("monitoring-locations", "monitoring_location_id")`. #' The default (`NA`) will return all columns of the data. +#' @param \dots Not used. Included to help differentiate official Water Data API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. +#' @param q Full-text search across the most relevant text fields for this collection +#' (e.g. site name, identifier, number, state, county, and site type). +#' Matching rules: +#' - Case-insensitive, with prefix matching (e.g. poud matches POUDRE). +#' - Words separated by spaces are AND'd together (all must match). +#' - Terms separated by commas are OR'd together (any may match). +#' - Common abbreviations are expanded, so river also matches sites stored as RV (and vice versa). +#' Examples are: +#' q=poudre - sites whose name/identifier starts with or contains poudre +#' q=colorado river - sites matching both colorado and river/rv +#' q=poudre,cache creek - sites matching poudre OR (cache AND creek/ck) +#' #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api #' @examplesIf is_dataRetrieval_user() @@ -80,6 +97,7 @@ #' bbox_vals = c(-94.00, 35.0, -93.5, 35.5) #' multi_site <- read_waterdata_monitoring_location(bbox = bbox_vals) #' +#' poudre <- read_waterdata_monitoring_location(q = "poudre") #' #' } read_waterdata_monitoring_location <- function( @@ -123,7 +141,11 @@ read_waterdata_monitoring_location <- function( well_constructed_depth = NA_character_, hole_constructed_depth = NA_character_, depth_source_code = NA_character_, + revision_note = NA_character_, + revision_created = NA_character_, + revision_modified = NA_character_, properties = NA_character_, + q = NA_character_, bbox = NA, skipGeometry = NA, ..., diff --git a/R/read_waterdata_peaks.R b/R/read_waterdata_peaks.R index 216b91300..dcb84b8b4 100644 --- a/R/read_waterdata_peaks.R +++ b/R/read_waterdata_peaks.R @@ -22,6 +22,7 @@ #' @param day `r get_ogc_params("peaks")$day` #' @param time_of_day `r get_ogc_params("peaks")$time_of_day` #' @param peak_since `r get_ogc_params("peaks")$peak_since` +#' @param qualifier `r get_ogc_params("peaks")$qualifier` #' @param properties A vector of requested columns to be returned from the query. #' Available options are: #' `r dataRetrieval:::get_properties_for_docs("peaks", "peak_id")`. @@ -35,8 +36,13 @@ #' or whether to set those dates to `NA` (`FALSE`). Peaks with uncertain days #' are stored on the first of the month, and those with uncertain #' month stored on January 1. Default is `FALSE`. +#' @param \dots Arguments that can be queried, +#' but are not returned. These are used as alternatives to specifying specific +#' monitoring_location_ids. See `?get_monitoring_location_arguments` +#' for available arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api +#' @seealso [get_monitoring_location_arguments()] #' #' @inherit read_waterdata_continuous details #' @@ -53,6 +59,11 @@ #' monitoring_location_id = wi_peaks$monitoring_location_id[1], #' parameter_code = "00060") #' +#' dane <- read_waterdata_peaks( +#' state_name = "Wisconsin", +#' county_name = "Dane County", +#' parameter_code = "00060") +#' #' incomplete_dates_not_allowed <- read_waterdata_peaks( #' monitoring_location_id = "USGS-06334330", #' parameter_code = "00060") @@ -78,6 +89,7 @@ read_waterdata_peaks <- function( day = NA_character_, time_of_day = NA_character_, peak_since = NA_character_, + qualifier = NA_character_, skipGeometry = NA, time = NA_character_, bbox = NA, @@ -91,9 +103,15 @@ read_waterdata_peaks <- function( ) { service <- "peaks" output_id <- "peak_id" - rlang::check_dots_empty() args <- mget(names(formals())) + + args <- cleanup_arguments( + args = args, + monitoring_location_arguments = list(...), + service = service + ) + args[["allow_incomplete_dates"]] <- NULL return_list <- get_ogc_data(args, output_id, service) diff --git a/R/read_waterdata_ratings.R b/R/read_waterdata_ratings.R index 3663592af..3bb181211 100644 --- a/R/read_waterdata_ratings.R +++ b/R/read_waterdata_ratings.R @@ -38,7 +38,13 @@ #' @export #' @inherit read_waterdata_continuous details #' -#' @return List of data frames which contain the requested rating curves. +#' @return List of named lists, one per requested rating file. Each element +#' contains: +#' \describe{ +#' \item{ratings}{Data frame of the rating curve.} +#' \item{metadata}{Data frame of header/value pairs parsed from the comment +#' attribute of the ratings file.} +#' } #' #' @examplesIf is_dataRetrieval_user() #' @@ -49,20 +55,24 @@ #' monitoring_location_id = monitoring_location_id, #' file_type = "exsa") #' -#' head(ratings_exsa[["USGS-01104475.exsa.rdb"]]) -#' comment(ratings_exsa[["USGS-01104475.exsa.rdb"]])[1:15] +#' head(ratings_exsa[["USGS-01104475.exsa.rdb"]]$ratings) +#' m1 <- ratings_exsa[["USGS-01104475.exsa.rdb"]]$metadata +#' m1 #' #' ratings_corr <- read_waterdata_ratings( #' monitoring_location_id = monitoring_location_id, #' file_type = "corr") #' -#' head(ratings_corr[["USGS-01104460.corr.rdb"]]) -#' comment(ratings_corr[["USGS-01104460.corr.rdb"]])[1:15] +#' head(ratings_corr[["USGS-01104460.corr.rdb"]]$ratings) +#' m2 <- ratings_corr[["USGS-01104460.corr.rdb"]]$metadata +#' m2 #' #' rating_2 <- read_waterdata_ratings( #' monitoring_location_id = monitoring_location_id, #' file_type = c("corr", "exsa")) #' names(rating_2) +#' m3 <- rating_2$`USGS-01104460.exsa.rdb`$metadata +#' rat_data <- rating_2$`USGS-01104460.exsa.rdb`$ratings #' #' bbox <- c(-95.00, 40.0, -92.0, 42) #' @@ -72,7 +82,6 @@ #' recent_query <- read_waterdata_ratings(bbox = bbox, #' datetime = c(Sys.Date()-7, NA), #' download_and_parse = FALSE) -#' length(recent_query) #'} read_waterdata_ratings <- function( monitoring_location_id = NA_character_, @@ -147,6 +156,8 @@ read_waterdata_ratings <- function( httr2::req_url_query(limit = limit) |> basic_request() + message("Requesting:\n", request$url) + resp <- httr2::req_perform(request) log_rate_limit(resp) @@ -168,6 +179,7 @@ read_waterdata_ratings <- function( } } +# Download and convert a rating curve feature to a tidy list download_convert <- function(feature, file_path, file_type) { links <- feature$links id <- feature$id @@ -181,8 +193,105 @@ download_convert <- function(feature, file_path, file_type) { message("Requesting: \n", url) resp <- httr2::req_perform(req, path = full_file_path) rating <- importRDB1(full_file_path) - return(rating) + return(list( + ratings = rating, + metadata = parse_ratings_metadata(rating) + )) } return(NULL) } + +# Parse a single key=value or key="value" token into a named list +parse_kv_tokens <- function(line) { + kv_pat <- '([A-Za-z0-9_]+)\\s*=\\s*"([^"]*)"|([A-Za-z0-9_]+)\\s*=\\s*(\\S+)' + m <- gregexpr(kv_pat, line, perl = TRUE) + tokens <- regmatches(line, m)[[1]] + result <- list() + for (tok in tokens) { + key <- sub("^([A-Za-z0-9_]+)\\s*=.*", "\\1", tok, perl = TRUE) + val <- sub('^[A-Za-z0-9_]+\\s*=\\s*"?([^"]*)"?$', "\\1", tok, perl = TRUE) + result[[key]] <- val + } + result +} + + +parse_ratings_metadata <- function(ratings_df) { + raw_comments <- comment(ratings_df) + + if (is.null(raw_comments)) { + return(data.frame()) + } + + # strip leading # // or // + lines <- sub("^#\\s*//?\\s*", "", raw_comments) + lines <- sub("^//\\s*", "", lines) + lines <- trimws(lines) + lines <- lines[lines != ""] + + # collect WARNING lines + warn_idx <- grepl("^WARNING", lines) + warn_text <- trimws(sub("^WARNING\\s*", "", lines[warn_idx])) + warning_value <- paste(warn_text[warn_text != ""], collapse = " ") + lines <- lines[!warn_idx] + + # split each line into header and the rest + # header is the first all-caps+underscore token + header_pat <- "^([A-Z][A-Z0-9_]*)\\s*(.*)" + headers <- sub(header_pat, "\\1", lines, perl = TRUE) + bodies <- sub(header_pat, "\\2", lines, perl = TRUE) + + # group lines by header, preserving order of first appearance + unique_headers <- unique(headers) + + result <- list(WARNING = warning_value) + i <- 1 + for (hdr in unique_headers) { + idx <- which(headers == hdr) + body_lines <- bodies[idx] + + # parse each line's key=value pairs + parsed_rows <- lapply(body_lines, parse_kv_tokens) + + # check if any line has key=value pairs; if not, treat as plain text + has_kv <- sapply(parsed_rows, length) > 0 + + if (any(has_kv)) { + p_rows <- unlist(parsed_rows) + if (anyDuplicated(names(p_rows))) { + columns <- unique(names(p_rows)) + df <- data.frame(matrix( + NA_character_, + nrow = length(p_rows) / length(columns), + ncol = length(columns) + )) + names(df) <- columns + for (i in columns) { + df[[i]] <- p_rows[names(p_rows) %in% i] + } + } else { + df <- data.frame(t(p_rows)) + } + + if (nrow(df) == 1 && ncol(df) == 1) { + result[[hdr]] <- df[[1]] + } else { + result[[hdr]] <- df + } + } else { + if (substr(body_lines, start = 1, stop = 1) == "=") { + result[[hdr]] <- substr(body_lines, start = 2, stop = nchar(body_lines)) + } else { + comment_label <- paste("Comment", i) + result[[comment_label]] <- paste( + trimws(c(hdr, body_lines)), + collapse = " " + ) + i <- i + 1 + } + } + } + + return(result) +} diff --git a/R/read_waterdata_ts_meta.R b/R/read_waterdata_ts_meta.R index b3f869dec..0b06a704f 100644 --- a/R/read_waterdata_ts_meta.R +++ b/R/read_waterdata_ts_meta.R @@ -45,6 +45,8 @@ #' `r dataRetrieval:::get_properties_for_docs("time-series-metadata", "time_series_id")`. #' The default (`NA`) will return all columns of the data. #' @param time_series_id `r get_ogc_params("time-series-metadata")$id` +#' @param \dots Not used. Included to help differentiate official Water Data API arguments +#' from more seldom used, optional dataRetrieval-specific arguments. #' @inheritParams check_arguments_api #' @inheritParams check_arguments_non_api #' diff --git a/R/setAccess.R b/R/setAccess.R index f3bdb87c5..f0bda6838 100644 --- a/R/setAccess.R +++ b/R/setAccess.R @@ -76,6 +76,5 @@ Please contact comptools@usgs.gov for more information." pkg.env$samplesData <- "https://api.waterdata.usgs.gov/samples-data/summary" pkg.env$status <- "https://www.waterqualitydata.us/wqx3/status/" - pkg.env$NGWMN <- "https://cida.usgs.gov/ngwmn_cache/sos" # nolint end } diff --git a/R/sysdata.rda b/R/sysdata.rda index 76776c7db..986927ec0 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/walk_pages.R b/R/walk_pages.R index c703bd3af..1d4f63f16 100644 --- a/R/walk_pages.R +++ b/R/walk_pages.R @@ -11,13 +11,13 @@ walk_pages <- function(req) { max_reqs = Inf, on_error = "stop" ) - + failures <- resps |> httr2::resps_failures() - + return_list <- resps |> httr2::resps_successes() |> httr2::resps_data(\(resp) get_resp_data(resp)) - + return(return_list) } @@ -34,33 +34,30 @@ walk_pages <- function(req) { get_resp_data <- function(resp) { body <- httr2::resp_body_json(resp) use_sf <- !grepl("skipGeometry=true", resp$url, ignore.case = TRUE) - + if (isTRUE(body[["numberReturned"]] == 0)) { return(data.frame()) } - + return_df <- sf::read_sf(httr2::resp_body_string(resp)) - + return_df <- coerce_num_cols(return_df, is_sf = TRUE) - - if ("qualifier" %in% names(return_df)) { - return_df$qualifier <- as.character(vapply( - X = return_df$qualifier, - FUN = function(x) { - x[is.na(x)] <- "" - paste(x, collapse = ", ") - }, - FUN.VALUE = c(NA_character_) - )) + + return_df <- coerce_time_cols(return_df, is_sf = TRUE) + + return_df <- coerce_qualifier_cols(return_df, is_sf = TRUE) + + if ("altitude_accuracy" %in% names(return_df)) { + return_df$altitude_accuracy <- as.character(return_df$altitude_accuracy) } - + if (!use_sf) { return_df <- sf::st_drop_geometry(return_df) if ("AsGeoJSON(geometry)" %in% names(return_df)) { return_df <- return_df[, !names(return_df) %in% "AsGeoJSON(geometry)"] } } - + return(return_df) } @@ -77,24 +74,24 @@ get_resp_data <- function(resp) { #' next_req_url <- function(resp, req) { body <- httr2::resp_body_json(resp) - + if (isTRUE(body[["code"]] == "InvalidQuery")) { message(body[["description"]]) return(NULL) } - + if (isTRUE(body[["numberReturned"]] == 0)) { return(NULL) } - + log_rate_limit(resp) if ("links" %in% names(body)) { links <- body$links if (any(sapply(links, function(x) x$rel) == "next")) { next_index <- which(sapply(links, function(x) x$rel) == "next") - + next_url <- links[[next_index]][["href"]] - + return(httr2::req_url(req = req, url = next_url)) } } else if (!is.null(body[["next"]])) { @@ -108,9 +105,9 @@ next_req_url <- function(resp, req) { get_csv <- function(req, limit) { skip_geo <- grepl("skipGeometry=true", req$url, ignore.case = TRUE) resp <- httr2::req_perform(req) - + log_rate_limit(resp) - + if (httr2::resp_has_body(resp)) { return_list <- httr2::resp_body_string(resp) df <- data.table::fread( @@ -118,9 +115,11 @@ get_csv <- function(req, limit) { data.table = FALSE, colClasses = "character" ) - - df <- coerce_num_cols(df) - + + df <- coerce_num_cols(df, is_sf = FALSE) + + df <- coerce_time_cols(df, is_sf = FALSE) + if (skip_geo) { df <- df[, names(df)[!names(df) %in% c("x", "y")]] } else { @@ -129,7 +128,7 @@ get_csv <- function(req, limit) { sf::st_crs(df) <- 4269 } } - + if (nrow(df) == limit) { warning( "Missing data is probable. Use no_paging = FALSE to @@ -139,7 +138,40 @@ ensure all requested data is returned." } else { df <- data.frame() } + + return(df) +} + +coerce_qualifier_cols <- function(df, is_sf = FALSE){ + + if ("qualifier" %in% names(df)) { + df$qualifier <- as.character(vapply( + X = df$qualifier, + FUN = function(x) { + x[is.na(x)] <- "" + paste(x, collapse = ", ") + }, + FUN.VALUE = c(NA_character_) + )) + } + return(df) +} +coerce_time_cols <- function(df, is_sf = FALSE){ + included_time_cols <- names(df)[names(df) %in% time_periods] + if (length(included_time_cols) == 0) { + return(df) + } + + check_df <- if (is_sf) { + sf::st_drop_geometry(df[, included_time_cols, drop = FALSE]) + } else { + df[, included_time_cols, drop = FALSE] + } + + if (any(vapply(check_df, is.character, TRUE))) { + df[, included_time_cols] <- lapply(check_df, function(x) as.POSIXct(x, tz = "UTC")) + } return(df) } @@ -148,13 +180,13 @@ coerce_num_cols <- function(df, is_sf = FALSE) { if (length(included_num_cols) == 0) { return(df) } - + check_df <- if (is_sf) { sf::st_drop_geometry(df[, included_num_cols, drop = FALSE]) } else { df[, included_num_cols, drop = FALSE] } - + if (!all(vapply(check_df, is.numeric, logical(1)))) { df[, included_num_cols] <- lapply(check_df, as.numeric) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 6dc8a7711..d40aaa82a 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -65,6 +65,10 @@ navbar: - text: How to Contribute href: articles/Contributing.html right: + - text: News + href: news/index.html + - icon: fa-gitlab fa-lg + href: https://code.usgs.gov/water/dataRetrieval - icon: fa-github fa-lg href: https://github.com/DOI-USGS/dataRetrieval reference: @@ -79,18 +83,19 @@ reference: - read_waterdata_monitoring_location - read_waterdata_latest_continuous - read_waterdata_latest_daily + - read_waterdata_latest_field_measurements - read_waterdata_field_measurements - read_waterdata_parameter_codes - read_waterdata_metadata - read_waterdata - - summarize_waterdata_samples - - check_waterdata_sample_params - - get_ogc_params - read_waterdata_channel - read_waterdata_field_meta - read_waterdata_combined_meta - read_waterdata_ratings - read_waterdata_peaks + - summarize_waterdata_samples + - check_waterdata_sample_params + - get_monitoring_location_arguments - title: National Water Information System (NWIS) desc: Functions to retrieve (USGS) NWIS data. These will be slowly phased out and replaced with the read_waterdata family of functions. contents: @@ -119,9 +124,12 @@ reference: - title: National Ground-Water Monitoring Network desc: Functions to retrieve NGWMN data. contents: - - readNGWMNlevels - - readNGWMNsites - - readNGWMNdata + - read_ngwmn_water_level + - read_ngwmn_sites + - read_ngwmn_providers + - read_ngwmn_well_construction + - read_ngwmn_lithology + - read_ngwmn - title: Network Linked Data Index desc: Functions to interface with the NLDI. contents: @@ -161,3 +169,4 @@ reference: - getWebServiceData - is_dataRetrieval_user - checkWQPdates + - get_ogc_params diff --git a/man/check_OGC_requests.Rd b/man/check_OGC_requests.Rd index 1d7297967..00ad8002e 100644 --- a/man/check_OGC_requests.Rd +++ b/man/check_OGC_requests.Rd @@ -4,12 +4,14 @@ \alias{check_OGC_requests} \title{Check OGC requests} \usage{ -check_OGC_requests(endpoint = "daily", type = "queryables") +check_OGC_requests(endpoint = "daily", type = "queryables", base = "OGC") } \arguments{ \item{endpoint}{Character, can be any existing collection} \item{type}{Character, can be "queryables", "schema"} + +\item{base}{Character, can be "OGC" or "NGWMN"} } \value{ list @@ -30,6 +32,10 @@ ts_meta_queryables <- check_OGC_requests(endpoint = "time-series-metadata", type = "queryables") ts_meta_schema <- check_OGC_requests(endpoint = "time-series-metadata", type = "schema") + +ngwml <- check_OGC_requests(endpoint = "waterLevelObs", + type = "schema", + base = "NGWMN") } \dontshow{\}) # examplesIf} } diff --git a/man/check_arguments_non_api.Rd b/man/check_arguments_non_api.Rd index 193ab821a..bf59ebb93 100644 --- a/man/check_arguments_non_api.Rd +++ b/man/check_arguments_non_api.Rd @@ -9,8 +9,7 @@ check_arguments_non_api( no_paging, limit, attach_request, - chunk_size, - ... + chunk_size ) } \arguments{ @@ -40,9 +39,6 @@ is 250, while the default for time series functions is 10. Setting to \code{NA} will eliminate site chunking, giving users full control.} - -\item{\dots}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} } \description{ Function to check types and create parameter descriptions. diff --git a/man/construct_api_requests.Rd b/man/construct_api_requests.Rd index cbad05506..98656b981 100644 --- a/man/construct_api_requests.Rd +++ b/man/construct_api_requests.Rd @@ -9,6 +9,7 @@ construct_api_requests( output_id, ..., bbox = NA, + base = "OGC", convertType = getOption("dataRetrieval.convertType"), no_paging = getOption("dataRetrieval.no_paging"), chunk_size = getOption("dataRetrieval.site_chunk_size_data"), diff --git a/man/get_monitoring_location_arguments.Rd b/man/get_monitoring_location_arguments.Rd new file mode 100644 index 000000000..57a146af7 --- /dev/null +++ b/man/get_monitoring_location_arguments.Rd @@ -0,0 +1,157 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_monitoring_location_arguments.R +\name{get_monitoring_location_arguments} +\alias{get_monitoring_location_arguments} +\title{Get Monitoring Location Arguments} +\usage{ +get_monitoring_location_arguments( + service = "daily", + agency_code = NA_character_, + agency_name = NA_character_, + monitoring_location_number = NA_character_, + monitoring_location_name = NA_character_, + district_code = NA_character_, + country_code = NA_character_, + country_name = NA_character_, + state_code = NA_character_, + state_name = NA_character_, + county_code = NA_character_, + county_name = NA_character_, + minor_civil_division_code = NA_character_, + site_type_code = NA_character_, + site_type = NA_character_, + hydrologic_unit_code = NA_character_, + basin_code = NA_character_, + altitude = NA_character_, + altitude_accuracy = NA_character_, + altitude_method_code = NA_character_, + altitude_method_name = NA_character_, + vertical_datum = NA_character_, + vertical_datum_name = NA_character_, + horizontal_positional_accuracy_code = NA_character_, + horizontal_positional_accuracy = NA_character_, + horizontal_position_method_code = NA_character_, + horizontal_position_method_name = NA_character_, + original_horizontal_datum = NA_character_, + original_horizontal_datum_name = NA_character_, + drainage_area = NA_character_, + contributing_drainage_area = NA_character_, + time_zone_abbreviation = NA_character_, + uses_daylight_savings = NA_character_, + construction_date = NA_character_, + aquifer_code = NA_character_, + national_aquifer_code = NA_character_, + aquifer_type_code = NA_character_, + well_constructed_depth = NA_character_, + hole_constructed_depth = NA_character_, + depth_source_code = NA_character_, + data_gap_interval = NA_character_, + ..., + check_arguments = FALSE +) +} +\arguments{ +\item{service}{Endpoint to check arguments against. Possible values are +"daily", "latest-continuous", "field-measurements", "latest-daily", +"latest-field-measurements", "continuous", "peaks".} + +\item{agency_code}{The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/agency-codes/items}.} + +\item{agency_name}{The name of the agency that is reporting the data.} + +\item{monitoring_location_number}{Each monitoring location in the USGS data base has a unique 8- to 15-digit identification number.} + +\item{monitoring_location_name}{This is the official name of the monitoring location in the database. For well information this can be a district-assigned local number.} + +\item{district_code}{The Water Science Centers (WSCs) across the United States use the FIPS state code as the district code. In some case, monitoring locations and samples may be managed by a water science center that is adjacent to the state in which the monitoring location actually resides. For example a monitoring location may have a district code of 30 which translates to Montana, but the state code could be 56 for Wyoming because that is where the monitoring location actually is located.} + +\item{country_code}{The code for the country in which the monitoring location is located.} + +\item{country_name}{The name of the country in which the monitoring location is located.} + +\item{state_code}{State code. A \href{https://www2.census.gov/geo/docs/reference/state.txt}{two-digit ANSI code} (formerly FIPS code) as defined by the American National Standards Institute, to define States and equivalents. A three-digit ANSI code is used to define counties and county equivalents. \href{https://www.census.gov/library/reference/code-lists/ansi.html#states}{A lookup table is available.} The only countries with political subdivisions other than the US are Mexico and Canada. The Mexican states have US state codes ranging from 81-86 and Canadian provinces have state codes ranging from 90-98.} + +\item{state_name}{The name of the state or state equivalent in which the monitoring location is located.} + +\item{county_code}{The code for the county or county equivalent (parish, borough, etc.) in which the monitoring location is located. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/counties/items}.} + +\item{county_name}{The name of the county or county equivalent (parish, borough, etc.) in which the monitoring location is located. [A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/counties/items}.} + +\item{minor_civil_division_code}{Codes for primary governmental or administrative divisions of the county or county equivalent in which the monitoring location is located.} + +\item{site_type_code}{A code describing the hydrologic setting of the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/site-types/items}.} + +\item{site_type}{A description of the hydrologic setting of the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/site-types/items}.} + +\item{hydrologic_unit_code}{The hydrologic unit code (HUC) for the monitoring location. Supports prefix matching — querying with a shorter HUC (e.g. "04") matches all locations within that hydrologic region.} + +\item{basin_code}{The Basin Code or "drainage basin code" is a two-digit code that further subdivides the 8-digit hydrologic-unit code. The drainage basin code is defined by the USGS State Office where the monitoring location is located.} + +\item{altitude}{Altitude of the monitoring location referenced to the specified Vertical Datum.} + +\item{altitude_accuracy}{Accuracy of the altitude, in feet. An accuracy of +/- 0.1 foot would be entered as “.1”. Many altitudes are interpolated from the contours on topographic maps; accuracies determined in this way are generally entered as one-half of the contour interval.} + +\item{altitude_method_code}{Codes representing the method used to measure altitude.} + +\item{altitude_method_name}{The name of the method used to measure altitude.} + +\item{vertical_datum}{The datum used to determine altitude and vertical position at the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/altitude-datums/items}.} + +\item{vertical_datum_name}{The datum used to determine altitude and vertical position at the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/altitude-datums/items}.} + +\item{horizontal_positional_accuracy_code}{Indicates the accuracy of the latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-accuracy-codes/items}.} + +\item{horizontal_positional_accuracy}{The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/agency-codes/items}.} + +\item{horizontal_position_method_code}{Indicates the method used to determine latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-method-codes/items}.} + +\item{horizontal_position_method_name}{Indicates the method used to determine latitude longitude values. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-method-codes/items}.} + +\item{original_horizontal_datum}{Coordinates are published in EPSG:4326 / WGS84 / World Geodetic System 1984. This field indicates the original datum used to determine coordinates before they were converted. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-datum-codes/items}.} + +\item{original_horizontal_datum_name}{Coordinates are published in EPSG:4326 / WGS84 / World Geodetic System 1984. This field indicates the original datum used to determine coordinates before they were converted. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/coordinate-datum-codes/items}.} + +\item{drainage_area}{The area enclosed by a topographic divide from which direct surface runoff from precipitation normally drains by gravity into the stream above that point.} + +\item{contributing_drainage_area}{The contributing drainage area of a lake, stream, wetland, or estuary monitoring location, in square miles. This item should be present only if the contributing area is different from the total drainage area. This situation can occur when part of the drainage area consists of very porous soil or depressions that either allow all runoff to enter the groundwater or traps the water in ponds so that rainfall does not contribute to runoff. A transbasin diversion can also affect the total drainage area.} + +\item{time_zone_abbreviation}{A short code describing the time zone used by a monitoring location.} + +\item{uses_daylight_savings}{The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/agency-codes/items}.} + +\item{construction_date}{Date the well was completed.} + +\item{aquifer_code}{Local aquifers in the USGS water resources data base are identified by a geohydrologic unit code (a three-digit number related to the age of the formation, followed by a 4 or 5 character abbreviation for the geologic unit or aquifer name).} + +\item{national_aquifer_code}{National aquifers are the principal aquifers or aquifer systems in the United States, defined as regionally extensive aquifers or aquifer systems that have the potential to be used as a source of potable water. Not all groundwater monitoring locations can be associated with a National Aquifer. Such monitoring locations will not be retrieved using this search criteria. A list of National aquifer codes and names is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/national-aquifer-codes/items}.} + +\item{aquifer_type_code}{The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/agency-codes/items}.} + +\item{well_constructed_depth}{The depth of the finished well, in feet below land surface datum. Note: Not all groundwater monitoring locations have information on Well Depth. Such monitoring locations will not be retrieved using this search criteria.} + +\item{hole_constructed_depth}{The total depth to which the hole is drilled, in feet below land surface datum. Note: Not all groundwater monitoring locations have information on Hole Depth. Such monitoring locations will not be retrieved using this search criteria.} + +\item{depth_source_code}{A code indicating the source of water-level data.} + +\item{data_gap_interval}{The time interval threshold used for gap detection in the time series.} + +\item{\dots}{Not used. Used to make sure the user isn't passing in arguments that aren't available.} + +\item{check_arguments}{Logical. Used to decide if the arguments passed in are available or not. The +default is \code{FALSE}. Using \code{TRUE} will make two calls to the API, so if you are concerned +with minimizing API calls, keep this value as \code{FALSE}. If you are concerned with +making sure your calls are accepted by the service, set to \code{TRUE}.} +} +\description{ +Many read_waterdata functions have a long list of arguments that can be used +to find sites that have data. Users can use this function as a reference +of possible arguments that can be used as input. +Additionally, this function is also used by other functions to check that +the user supplied parameters are available to their queries +} +\examples{ + +get_monitoring_location_arguments(service = "daily", agency_name = "USGS") +get_monitoring_location_arguments(service = "field-measurements", + state_name = c("Ohio", "Wisconsin")) +} diff --git a/man/get_ogc_params.Rd b/man/get_ogc_params.Rd index 9a8ab0d08..d7fe7bdc3 100644 --- a/man/get_ogc_params.Rd +++ b/man/get_ogc_params.Rd @@ -4,10 +4,12 @@ \alias{get_ogc_params} \title{Get parameter descriptions} \usage{ -get_ogc_params(service) +get_ogc_params(service, base = "OGC") } \arguments{ \item{service}{Character, can be any of the USGS Waterdata API endpoints or collections.} + +\item{base}{Either "OGC" for waterdata, or "NGWMN" for National Groundwater Monitoring Network.} } \value{ list diff --git a/man/readNGWMNdata.Rd b/man/readNGWMNdata.Rd deleted file mode 100644 index c2dd649b1..000000000 --- a/man/readNGWMNdata.Rd +++ /dev/null @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readNGWMNdata.R -\name{readNGWMNdata} -\alias{readNGWMNdata} -\title{Import data from the National Groundwater Monitoring Network.} -\usage{ -readNGWMNdata(service, ..., asDateTime = TRUE, tz = "UTC") -} -\arguments{ -\item{service}{char Service for the request - "observation" and "featureOfInterest" are implemented.} - -\item{\dots}{Other parameters to supply, namely \code{siteNumbers} or \code{bbox}} - -\item{asDateTime}{logical if \code{TRUE}, will convert times to POSIXct format. Currently defaults to -\code{FALSE} since time zone information is not included.} - -\item{tz}{character to set timezone attribute of dateTime. Default is "UTC", and converts the -date times to UTC, properly accounting for daylight savings times based on the data's provided time zone offset. -Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", -"America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu", -"America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also \code{OlsonNames()} -for more information on time zones.} -} -\description{ -Only water level data and site locations and names are currently available through the web service. -} -\examples{ -\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} -\donttest{ -# one site -site <- "USGS.430427089284901" -#oneSite <- readNGWMNdata(siteNumbers = site, service = "observation") - -# multiple sites -sites <- c("USGS.272838082142201", "USGS.404159100494601", "USGS.401216080362703") -# Very slow: -# multiSiteData <- readNGWMNdata(siteNumbers = sites, service = "observation") -# attributes(multiSiteData) - -# non-USGS site -# accepts colon or period between agency and ID -site <- "MBMG:702934" -# data <- readNGWMNdata(siteNumbers = site, service = "featureOfInterest") - -# bounding box -# bboxSites <- readNGWMNdata(service = "featureOfInterest", bbox = c(30, -102, 31, 99)) -# retrieve sites. Set asDateTime to false since one site has an invalid date -# Very slow: -# bboxData <- readNGWMNdata(service = "observation", siteNumbers = bboxSites$site[1:3], -# asDateTime = FALSE) -} -\dontshow{\}) # examplesIf} -} diff --git a/man/readNGWMNlevels.Rd b/man/readNGWMNlevels.Rd deleted file mode 100644 index c53e3787d..000000000 --- a/man/readNGWMNlevels.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readNGWMNdata.R -\name{readNGWMNlevels} -\alias{readNGWMNlevels} -\title{Retrieve groundwater levels from the National Ground Water Monitoring Network.} -\usage{ -readNGWMNlevels(siteNumbers, asDateTime = TRUE, tz = "UTC") -} -\arguments{ -\item{siteNumbers}{character Vector of feature IDs formatted with agency code and site number -separated by a period or semicolon, e.g. \code{USGS.404159100494601}.} - -\item{asDateTime}{logical Should dates and times be converted to date/time objects, -or returned as character? Defaults to \code{TRUE}. Must be set to \code{FALSE} if a site -contains non-standard dates.} - -\item{tz}{character to set timezone attribute of dateTime. Default is "UTC", and converts the -date times to UTC, properly accounting for daylight savings times based on the data's provided time zone offset. -Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", -"America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu", -"America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also \code{OlsonNames()} -for more information on time zones.} -} -\description{ -Retrieve groundwater levels from the National Ground Water Monitoring Network. -} -\examples{ -\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} -\donttest{ -# one site -site <- "USGS.430427089284901" -# oneSite <- readNGWMNlevels(siteNumbers = site) - -# multiple sites -sites <- c("USGS:272838082142201", "USGS:404159100494601", "USGS:401216080362703") -# multiSiteData <- readNGWMNlevels(sites) - -# non-USGS site -site <- "MBMG.103306" -# data <- readNGWMNlevels(siteNumbers = site, asDateTime = FALSE) - -# site with no data returns empty data frame -noDataSite <- "UTGS.401544112060301" -# noDataSite <- readNGWMNlevels(siteNumbers = noDataSite) -} -\dontshow{\}) # examplesIf} -} diff --git a/man/readNGWMNsites.Rd b/man/readNGWMNsites.Rd deleted file mode 100644 index 0aa0232bd..000000000 --- a/man/readNGWMNsites.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readNGWMNdata.R -\name{readNGWMNsites} -\alias{readNGWMNsites} -\title{Retrieve site data from the National Ground Water Monitoring Network.} -\usage{ -readNGWMNsites(siteNumbers) -} -\arguments{ -\item{siteNumbers}{character Vector of feature IDs formatted with agency code and site number -separated by a period or semicolon, e.g. \code{USGS.404159100494601}.} -} -\value{ -A data frame the following columns: -#' \tabular{lll}{ -Name \tab Type \tab Description \cr -site \tab char \tab Site FID \cr -description \tab char \tab Site description \cr -dec_lat_va, dec_lon_va \tab numeric \tab Site latitude and longitude \cr -} -} -\description{ -Retrieve site data from the National Ground Water Monitoring Network. -} -\examples{ -\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} -\donttest{ -# one site -site <- "USGS.430427089284901" -#oneSite <- readNGWMNsites(siteNumbers = site) - -# non-USGS site -site <- "MBMG.103306" -#siteInfo <- readNGWMNsites(siteNumbers = site) -} -\dontshow{\}) # examplesIf} -} diff --git a/man/readNWISdata.Rd b/man/readNWISdata.Rd index 2e66b64ac..8e47c060a 100644 --- a/man/readNWISdata.Rd +++ b/man/readNWISdata.Rd @@ -83,84 +83,6 @@ not be expressed in periods of less than a day, or in increments of months M or period returns data for a site generally from now to a time in the past. Note that when period is used all data up to the most recent value are returned. } -\examples{ -\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} -\donttest{ -# Examples not run for time considerations - -instFlow <- readNWISdata( - sites = "05114000", service = "iv", - parameterCd = "00060", - startDate = "2014-05-01T00:00Z", endDate = "2014-05-01T12:00Z" -) - -instFlowCDT <- readNWISdata( - sites = "05114000", service = "iv", - parameterCd = "00060", - startDate = "2014-05-01T00:00", endDate = "2014-05-01T12:00", - tz = "America/Chicago" -) - -multiSite <- readNWISdata( - sites = c("04025500", "040263491"), - service = "iv", parameterCd = "00060" -) - -waterYearStat <- readNWISdata( - site = c("01646500"), - service = "stat", - statReportType = "annual", - statYearType = "water", - missingData = "on" -) -monthlyStat <- readNWISdata( - site = c("01646500"), - service = "stat", - statReportType = "monthly" -) - -dailyStat <- readNWISdata( - site = c("01646500"), - service = "stat", - statReportType = "daily", - statType = c("p25", "p50", "p75", "min", "max"), - parameterCd = "00060" -) - -arg.list <- list( - site = "03111548", - statReportType = "daily", - statType = c("p25", "p50", "p75", "min", "max"), - parameterCd = "00060" -) -allDailyStats_2 <- readNWISdata(arg.list, service = "stat") - - -site_id <- "01594440" -rating_curve <- readNWISdata(service = "rating", site_no = site_id, file_type = "base") -all_sites_base <- readNWISdata(service = "rating", file_type = "base") -all_sites_core <- readNWISdata(service = "rating", file_type = "corr") -all_sites_exsa <- readNWISdata(service = "rating", file_type = "exsa") -all_sites_24hrs <- readNWISdata(service = "rating", file_type = "exsa", period = 24) - -peak_data <- readNWISdata( - service = "peak", - site_no = c("01594440", "040851325"), - range_selection = "data_range" -) - -peak_data <- readNWISdata( - service = "peak", - state_cd = "PA" -) - -peak_data <- readNWISdata( - service = "peak", - huc2_cd = "20" -) -} -\dontshow{\}) # examplesIf} -} \seealso{ \code{\link[=read_waterdata]{read_waterdata()}} } diff --git a/man/read_ngwmn.Rd b/man/read_ngwmn.Rd new file mode 100644 index 000000000..fd529e9d2 --- /dev/null +++ b/man/read_ngwmn.Rd @@ -0,0 +1,101 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_ngwmn.R +\name{read_ngwmn} +\alias{read_ngwmn} +\title{Generalized NGWMN API retrieval function} +\usage{ +read_ngwmn( + service, + CQL = NA_character_, + monitoring_location_id = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{service}{character, can be any existing collection. Can be: +"providers", "constructionObs", "waterLevelObs", "sites", or "lithologyObs". +The date of an observation. Date and time expressions adhere to RFC 3339. Intervals may be bounded or half-bounded (double-dots at start or end). +Examples: +\itemize{ +\item A date-time: "2018-02-12T23:20:50-00:00" +\item A bounded interval:"2018-02-12T00:00:00+05:00/2018-03-18T12:31:12+05:00" +\item Half-bounded intervals: "2018-02-12T00:00:00-05:00/.." or "../2018-03-18T12:31:12-05:00" +} + +Only features that have a \code{sample_time} that intersects the value of datetime are selected. If a feature has multiple temporal properties, it is the decision of the server whether only a single temporal property is used to determine the extent or all relevant temporal properties. + +See also Details below for more information.} + +\item{CQL}{A string in a Common Query Language format.} + +\item{monitoring_location_id}{This field is required. Combined site identifier of agency code and site number (format of \code{{agency_code}}-\code{{monitoring_location_number}}). A list of values can be passed for this field, seperated by commas.} + +\item{\dots}{Additional arguments to send to the request.} + +\item{convertType}{logical, defaults to \code{TRUE}. If \code{TRUE}, the function +will convert the data to dates and qualifier to string vector.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +Function that allows complex CQL queries on National Groundwater +Monitoring Network API. +See \url{https://api.waterdata.usgs.gov/docs/ogcapi/complex-queries/} +for more information. +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ +cql <- '{ + "op": "between", + "args": [ + { "property": "water_level_above_navd88_ft" }, + [ "100.00", "200.00" ] + ] +}' + +wl_data <- read_ngwmn(service = "waterLevelObs", + monitoring_location_id = c("USGS-272838082142201", + "USGS-404159100494601", + "USGS-401216080362703"), + CQL = cql) + +cql3 <- '{ +"op": "and", +"args": [ + { + "op": "between", + "args": [ + { "property": "water_level_above_navd88_ft" }, + [ "100.00", "200.00" ] + ] + }, + { + "op": "in", + "args": [ + { "property": "monitoring_location_id" }, + [ "USGS-272838082142201", "USGS-404159100494601", "USGS-401216080362703" ] + ] + } +] +}' + + +wl_data_alt <- read_ngwmn(service = "waterLevelObs", + CQL = cql3) + +} +\dontshow{\}) # examplesIf} +} diff --git a/man/read_ngwmn_lithology.Rd b/man/read_ngwmn_lithology.Rd new file mode 100644 index 000000000..27b9636ff --- /dev/null +++ b/man/read_ngwmn_lithology.Rd @@ -0,0 +1,77 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_ngwmn_lithology.R +\name{read_ngwmn_lithology} +\alias{read_ngwmn_lithology} +\title{Get NGWMN Lithology Observations} +\usage{ +read_ngwmn_lithology( + monitoring_location_id = NA_character_, + monitoring_location_obs_number = NA_character_, + properties = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{monitoring_location_id}{This field is required. Combined site identifier of agency code and site number (format of \code{{agency_code}}-\code{{monitoring_location_number}}). A list of values can be passed for this field, seperated by commas.} + +\item{monitoring_location_obs_number}{Number of observation for given site. A list of values can be passed for this field, seperated by commas.} + +\item{properties}{A vector of requested columns to be returned from the query. +Available options are: +agency_code, monitoring_location_number, monitoring_location_id, monitoring_location_obs_number, lithology_id, lithology_description, lithology_controlled_concept, lithology_depth_from, lithology_depth_to, lithology_depth_to_unit, lithology_depth_from_unit. +The default (\code{NA}) will return all columns of the data.} + +\item{\dots}{Not used. Included to help differentiate official NGWMN API arguments +from more seldom used, optional dataRetrieval-specific arguments.} + +\item{convertType}{logical, defaults to TRUE. +If \code{TRUE}, the function will convert the data to dates, any qualifiers to string +vector and reorder the returned data frame.} + +\item{no_paging}{logical, defaults to FALSE. +If \code{TRUE}, the data will +be requested from a native csv format. This can be dangerous because the +data will cut off at 50,000 rows without indication that more data +is available. Use \code{TRUE} with caution.} + +\item{chunk_size}{Number of monitoring_location_ids to chunk requests into. +The default for functions that don't generally return long-term data records +is 250, while +the default for time series functions is +10. +Setting to \code{NA} will eliminate site chunking, giving users full control.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +Lithology Observations data +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ +site <- "AKDNR-535134236016630" +ngwmn_lith <- read_ngwmn_lithology(monitoring_location_id = site) + + +sites <- c("ISWS-P428197", + "AKDNR-535143966816631", + "AKDNR-535134236016630") +ngwml_lith_sites <- read_ngwmn_lithology(monitoring_location_id = sites) + +} +\dontshow{\}) # examplesIf} +} diff --git a/man/read_ngwmn_providers.Rd b/man/read_ngwmn_providers.Rd new file mode 100644 index 000000000..6d128f88b --- /dev/null +++ b/man/read_ngwmn_providers.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_ngwmn_providers.R +\name{read_ngwmn_providers} +\alias{read_ngwmn_providers} +\title{Get NGWMN Provider Data} +\usage{ +read_ngwmn_providers( + state = NA_character_, + agency_code = NA_character_, + organization_type = NA_character_, + properties = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{state}{State code for provider. A list of values can be passed for this field, seperated by commas.} + +\item{agency_code}{Code for the name of the agency or organization that owns the site and/or contributed it to the network. A list of values can be passed for this field, seperated by commas.} + +\item{organization_type}{Type of organization of data provider.} + +\item{properties}{A vector of requested columns to be returned from the query. +Available options are: +agency_name, agency_code, organization_type, state, link. +The default (\code{NA}) will return all columns of the data.} + +\item{\dots}{Not used. Included to help differentiate official NGWMN API arguments +from more seldom used, optional dataRetrieval-specific arguments.} + +\item{convertType}{logical, defaults to TRUE. +If \code{TRUE}, the function will convert the data to dates, any qualifiers to string +vector and reorder the returned data frame.} + +\item{no_paging}{logical, defaults to FALSE. +If \code{TRUE}, the data will +be requested from a native csv format. This can be dangerous because the +data will cut off at 50,000 rows without indication that more data +is available. Use \code{TRUE} with caution.} + +\item{chunk_size}{Number of monitoring_location_ids to chunk requests into. +The default for functions that don't generally return long-term data records +is 250, while +the default for time series functions is +10. +Setting to \code{NA} will eliminate site chunking, giving users full control.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +NGWMN contributing providers +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ + +ngwmn_providers <- read_ngwmn_providers(state = "WI") + +ngwml_providers2 <- read_ngwmn_providers(state = c("WI", "CA", "AZ", "MN")) + +org_type <- read_ngwmn_providers(organization_type = "NWIS", state = c("WI", "MN")) + +} +\dontshow{\}) # examplesIf} +} diff --git a/man/read_ngwmn_sites.Rd b/man/read_ngwmn_sites.Rd new file mode 100644 index 000000000..35868f693 --- /dev/null +++ b/man/read_ngwmn_sites.Rd @@ -0,0 +1,156 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_ngwmn_sites.R +\name{read_ngwmn_sites} +\alias{read_ngwmn_sites} +\title{Get NGWMN Site Data} +\usage{ +read_ngwmn_sites( + monitoring_location_id = NA_character_, + agency_code = NA_character_, + monitoring_location_number = NA_character_, + altitude = NA_character_, + national_aquifer_code = NA_character_, + national_aquifer_description = NA_character_, + country_code = NA_character_, + country_name = NA_character_, + state_name = NA_character_, + county_name = NA_character_, + aquifer_name = NA_character_, + site_type = NA_character_, + aquifer_type_code = NA_character_, + qw_sys_name = NA_character_, + qw_sn_flag = NA_character_, + qw_baseline_flag = NA_character_, + qw_well_chars = NA_character_, + qw_well_type = NA_character_, + qw_well_purpose = NA_character_, + wl_sys_name = NA_character_, + wl_sn_flag = NA_character_, + wl_baseline_flag = NA_character_, + wl_well_chars = NA_character_, + wl_well_type = NA_character_, + wl_well_purpose = NA_character_, + bbox = NA, + properties = NA_character_, + skipGeometry = FALSE, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{monitoring_location_id}{Site identifier, combination of agency code and site number (format \code{agency_code}- \code{monitoring_location_number}). A list of values can be passed for this field, seperated by commas.} + +\item{agency_code}{Code for the name of the agency or organization that owns the site and/or contributed it to the network. A list of values can be passed for this field, seperated by commas.} + +\item{monitoring_location_number}{Local, unique well or spring identification number or code. A list of values can be passed for this field, seperated by commas.} + +\item{altitude}{Elevation of the land surface at the site.} + +\item{national_aquifer_code}{Code for U.S. Pricinpal Aquifer, lookup \href{https://www.usgs.gov/mission-areas/water-resources/science/national-aquifer-code-reference-list}{here}. A list of values can be passed for this field, seperated by commas.} + +\item{national_aquifer_description}{Name for U.S. Principal Aquifer, lookup \href{https://www.usgs.gov/mission-areas/water-resources/science/national-aquifer-code-reference-list}{here}. A list of values can be passed for this field, seperated by commas.} + +\item{country_code}{Abbreviation of country of site location. A list of values can be passed for this field, seperated by commas.} + +\item{country_name}{Name of country of site location.} + +\item{state_name}{Name of state of site location. A list of values can be passed for this field, seperated by commas.} + +\item{county_name}{Name of county of site location. A list of values can be passed for this field, seperated by commas.} + +\item{aquifer_name}{Name of local aquifer of site. A list of values can be passed for this field, seperated by commas.} + +\item{site_type}{Type of groundwater site (Spring or Well).} + +\item{aquifer_type_code}{Characteristic of the type of aquifer that the well is completed in (Confined or Unconfined). For NGWMN, shallow semi-confined wells can be considered unconfined if they respond to climatic fluctuations in a relatively short period of time.} + +\item{qw_sys_name}{The system from which water quality data from the well or spring is served to the portal. A list of values can be passed for this field, seperated by commas.} + +\item{qw_sn_flag}{Flag for whether the well or spring is part of the NGWMN water-quality network.} + +\item{qw_baseline_flag}{Flag for whether the well or spring has completed its 5-year baseline period, classifies it as being in one of the three QW subnetworks.} + +\item{qw_well_chars}{The characteristics of the aquifer the well represents. There are 3 options: 'Background', 'Suspected / Anticipated Changes', 'Known Changes'. The field is NULL if the site is still in the baseline period.} + +\item{qw_well_type}{Description of the assigned QW monitoring category for the well or spring.} + +\item{qw_well_purpose}{Description of the prupose of conducting QW monitoring of the well or spring.} + +\item{wl_sys_name}{The system from which water level data from the well or spring is served to the portal. A list of values can be passed for this field, seperated by commas.} + +\item{wl_sn_flag}{Flag for whether the well or spring is part of the NGWMN water-level network.} + +\item{wl_baseline_flag}{Flag for whether the well or spring has completed its 5-year baseline period, classifies it as being in one of the three WL subnetworks.} + +\item{wl_well_chars}{The characteristics of the aquifer the well represents. There are 3 options: 'Background', 'Suspected / Anticipated Changes', 'Known Changes'. The field is NULL if the site is still in the baseline period.} + +\item{wl_well_type}{Description of the assigned WL monitoring category for the well or spring} + +\item{wl_well_purpose}{Description of the purpose of conducting WL monitoring of the well or spring.} + +\item{bbox}{Only features that have a geometry that intersects the bounding +box are selected.The bounding box is provided as four or six numbers, depending +on whether the coordinate reference system includes a vertical axis (height or +depth). Coordinates are assumed to be in crs 4326. The expected format is a numeric +vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, +Southern-most latitude, Eastern-most longitude, Northern-most longitude).} + +\item{properties}{A vector of requested columns to be returned from the query. +Available options are: +geometry, monitoring_location_id, agency_code, agency_name, monitoring_location_number, monitoring_location_name, longitude, original_horizontal_datum, horizontal_position_accuracy_code, altitude, vertical_datum, altitude_method_name, altitude_accuracy, well_constructed_depth, well_depth_units, national_aquifer_code, national_aquifer_description, country_code, country_name, state_name, county_name, aquifer_name, site_type, aquifer_type_code, qw_sys_name, qw_sn_flag, qw_baseline_flag, qw_well_chars, qw_well_type, qw_well_purpose, qw_well_purpose_notes, wl_sys_name, wl_sn_flag, wl_baseline_flag, wl_well_chars, wl_well_type, wl_well_purpose, wl_well_purpose_notes, link. +The default (\code{NA}) will return all columns of the data.} + +\item{skipGeometry}{This option can be used to skip response geometries for +each feature. The returning object will be a data frame with no spatial +information.} + +\item{\dots}{Not used. Included to help differentiate official NGWMN API arguments +from more seldom used, optional dataRetrieval-specific arguments.} + +\item{convertType}{logical, defaults to TRUE. +If \code{TRUE}, the function will convert the data to dates, any qualifiers to string +vector and reorder the returned data frame.} + +\item{no_paging}{logical, defaults to FALSE. +If \code{TRUE}, the data will +be requested from a native csv format. This can be dangerous because the +data will cut off at 50,000 rows without indication that more data +is available. Use \code{TRUE} with caution.} + +\item{chunk_size}{Number of monitoring_location_ids to chunk requests into. +The default for functions that don't generally return long-term data records +is 250, while +the default for time series functions is +10. +Setting to \code{NA} will eliminate site chunking, giving users full control.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +Site data (from Monitoring Location Registry), including the name, identifier, agency, features, and location of the site +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ + +ngwmn_sites <- read_ngwmn_sites(state_name = "Minnesota") + +org_type <- read_ngwmn_sites(agency_code = "MN_DNR", + county_name = "Washington County") + +} +\dontshow{\}) # examplesIf} +} diff --git a/man/read_ngwmn_water_level.Rd b/man/read_ngwmn_water_level.Rd new file mode 100644 index 000000000..f0b95fe43 --- /dev/null +++ b/man/read_ngwmn_water_level.Rd @@ -0,0 +1,120 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_ngwmn_water_level.R +\name{read_ngwmn_water_level} +\alias{read_ngwmn_water_level} +\title{Get NGWMN Water Level Data} +\usage{ +read_ngwmn_water_level( + monitoring_location_id = NA_character_, + monitoring_location_obs_number = NA_character_, + sample_time = NA_character_, + data_provided_by = NA_character_, + water_depth_below_land_surface_ft = NA_character_, + water_level_above_site_datum_ft = NA_character_, + monitoring_location_vertical_datum = NA_character_, + water_level_above_navd88_ft = NA_character_, + properties = NA_character_, + datetime = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{monitoring_location_id}{This field is required. Combined site identifier of agency code and site number (format of \code{{agency_code}}-\code{{monitoring_location_number}}). A list of values can be passed for this field, seperated by commas.} + +\item{monitoring_location_obs_number}{Number of observation for given site. A list of values can be passed for this field, seperated by commas.} + +\item{sample_time}{The date of an observation. Date and time expressions adhere to RFC 3339. Intervals may be bounded or half-bounded (double-dots at start or end). +Examples: +\itemize{ +\item A date-time: "2018-02-12T23:20:50-00:00" +\item A bounded interval:"2018-02-12T00:00:00+05:00/2018-03-18T12:31:12+05:00" +\item Half-bounded intervals: "2018-02-12T00:00:00-05:00/.." or "../2018-03-18T12:31:12-05:00" +} + +Only features that have a \code{sample_time} that intersects the value of datetime are selected. If a feature has multiple temporal properties, it is the decision of the server whether only a single temporal property is used to determine the extent or all relevant temporal properties. + +See also Details below for more information.} + +\item{data_provided_by}{Code for the agency or organization that provides, collects, owns, and/or manages the water level measurement record.} + +\item{water_depth_below_land_surface_ft}{Calculated depth to water in feet.} + +\item{water_level_above_site_datum_ft}{Water-level value represented as depth to site datum in feet.} + +\item{monitoring_location_vertical_datum}{Code indicating the vertical datum.} + +\item{water_level_above_navd88_ft}{Mediated water-level value represented as depth to water relative to the NAVD88 datum.} + +\item{properties}{A vector of requested columns to be returned from the query. +Available options are: +agency_code, monitoring_location_number, monitoring_location_id, monitoring_location_obs_number, sample_time, orig_unit, orig_value, accuracy_unit, accuracy_value, obs_datum_cd, obs_comment, obs_method, data_provided_by, water_depth_below_land_surface_ft, water_level_above_site_datum_ft, monitoring_location_vertical_datum, water_level_above_navd88_ft. +The default (\code{NA}) will return all columns of the data.} + +\item{datetime}{The date of an observation. Date and time expressions adhere to RFC 3339. Intervals may be bounded or half-bounded (double-dots at start or end). +Examples: +\itemize{ +\item A date-time: "2018-02-12T23:20:50-00:00" +\item A bounded interval:"2018-02-12T00:00:00+05:00/2018-03-18T12:31:12+05:00" +\item Half-bounded intervals: "2018-02-12T00:00:00-05:00/.." or "../2018-03-18T12:31:12-05:00" +} + +Only features that have a \code{sample_time} that intersects the value of datetime are selected. If a feature has multiple temporal properties, it is the decision of the server whether only a single temporal property is used to determine the extent or all relevant temporal properties.} + +\item{\dots}{Not used. Included to help differentiate official NGWMN API arguments +from more seldom used, optional dataRetrieval-specific arguments.} + +\item{convertType}{logical, defaults to TRUE. +If \code{TRUE}, the function will convert the data to dates, any qualifiers to string +vector and reorder the returned data frame.} + +\item{no_paging}{logical, defaults to FALSE. +If \code{TRUE}, the data will +be requested from a native csv format. This can be dangerous because the +data will cut off at 50,000 rows without indication that more data +is available. Use \code{TRUE} with caution.} + +\item{chunk_size}{Number of monitoring_location_ids to chunk requests into. +The default for functions that don't generally return long-term data records +is 250, while +the default for time series functions is +10. +Setting to \code{NA} will eliminate site chunking, giving users full control.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +Water Level Observations data +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ +site <- "USGS-272838082142201" +ngwmn_wl <- read_ngwmn_water_level(monitoring_location_id = site) + +ngwmn_wl_sub <- read_ngwmn_water_level(monitoring_location_id = site, + monitoring_location_obs_number = 1:5) + +ngwml_wl_time2 <- read_ngwmn_water_level(monitoring_location_id = site, + datetime = c("2022-01-01", "2024-01-01")) + +sites <- c("USGS-272838082142201", "USGS-404159100494601", + "USGS-401216080362703", "MBMG-702934") +ngwml_wl_sites <- read_ngwmn_water_level(monitoring_location_id = sites) + +} +\dontshow{\}) # examplesIf} +} diff --git a/man/read_ngwmn_well_construction.Rd b/man/read_ngwmn_well_construction.Rd new file mode 100644 index 000000000..907f21c89 --- /dev/null +++ b/man/read_ngwmn_well_construction.Rd @@ -0,0 +1,81 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_ngwmn_well_construction.R +\name{read_ngwmn_well_construction} +\alias{read_ngwmn_well_construction} +\title{Get NGWMN Well Construction Data} +\usage{ +read_ngwmn_well_construction( + monitoring_location_id = NA_character_, + monitoring_location_obs_number = NA_character_, + material = NA_character_, + properties = NA_character_, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + chunk_size = getOption("dataRetrieval.site_chunk_size_data"), + limit = getOption("dataRetrieval.limit"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{monitoring_location_id}{This field is required. Combined site identifier of agency code and site number (format of \code{{agency_code}}-\code{{monitoring_location_number}}). A list of values can be passed for this field, seperated by commas.} + +\item{monitoring_location_obs_number}{Number of observation for given site. A list of values can be passed for this field, seperated by commas.} + +\item{material}{Screen type or material.} + +\item{properties}{A vector of requested columns to be returned from the query. +Available options are: +agency_code, monitoring_location_number, monitoring_location_id, monitoring_location_obs_number, type, depth_from, depth_to, depth_from_unit, depth_to_unit, material, diameter, diameter_unit, hole_size, hole_size_unit. +The default (\code{NA}) will return all columns of the data.} + +\item{\dots}{Not used. Included to help differentiate official NGWMN API arguments +from more seldom used, optional dataRetrieval-specific arguments.} + +\item{convertType}{logical, defaults to TRUE. +If \code{TRUE}, the function will convert the data to dates, any qualifiers to string +vector and reorder the returned data frame.} + +\item{no_paging}{logical, defaults to FALSE. +If \code{TRUE}, the data will +be requested from a native csv format. This can be dangerous because the +data will cut off at 50,000 rows without indication that more data +is available. Use \code{TRUE} with caution.} + +\item{chunk_size}{Number of monitoring_location_ids to chunk requests into. +The default for functions that don't generally return long-term data records +is 250, while +the default for time series functions is +10. +Setting to \code{NA} will eliminate site chunking, giving users full control.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +Well Construction Observations data +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ +site <- "USGS-272838082142201" +ngwmn_well <- read_ngwmn_well_construction(monitoring_location_id = site) + +ngwmn_well_sub <- read_ngwmn_well_construction(monitoring_location_id = site, + monitoring_location_obs_number = 2) + +sites <- c("USGS-272838082142201", "USGS-404159100494601", + "USGS-401216080362703", "MBMG-702934") +ngwml_well_sites <- read_ngwmn_well_construction(monitoring_location_id = sites) + +} +\dontshow{\}) # examplesIf} +} diff --git a/man/read_waterdata_channel.Rd b/man/read_waterdata_channel.Rd index e9bee3b98..9f7e0c0ef 100644 --- a/man/read_waterdata_channel.Rd +++ b/man/read_waterdata_channel.Rd @@ -132,7 +132,7 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments +\item{\dots}{Not used. Included to help differentiate official Water Data API arguments from more seldom used, optional dataRetrieval-specific arguments.} \item{convertType}{logical, defaults to TRUE. diff --git a/man/read_waterdata_combined_meta.Rd b/man/read_waterdata_combined_meta.Rd index 4e7a3519a..8f3f01002 100644 --- a/man/read_waterdata_combined_meta.Rd +++ b/man/read_waterdata_combined_meta.Rd @@ -185,7 +185,7 @@ See also Details below for more information.} \item{site_type}{A description of the hydrologic setting of the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/site-types/items}.} -\item{hydrologic_unit_code}{The United States is divided and sub-divided into successively smaller hydrologic units which are classified into four levels: regions, sub-regions, accounting units, and cataloging units. The hydrologic units are arranged within each other, from the smallest (cataloging units) to the largest (regions). Each hydrologic unit is identified by a unique hydrologic unit code (HUC) consisting of two to eight digits based on the four levels of classification in the hydrologic unit system.} +\item{hydrologic_unit_code}{The hydrologic unit code (HUC) for the monitoring location. Supports prefix matching — querying with a shorter HUC (e.g. "04") matches all locations within that hydrologic region.} \item{basin_code}{The Basin Code or "drainage basin code" is a two-digit code that further subdivides the 8-digit hydrologic-unit code. The drainage basin code is defined by the USGS State Office where the monitoring location is located.} @@ -237,7 +237,7 @@ See also Details below for more information.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, monitoring_location_id, agency_code, agency_name, monitoring_location_number, monitoring_location_name, district_code, country_code, country_name, state_code, state_name, county_code, county_name, minor_civil_division_code, site_type_code, site_type, hydrologic_unit_code, basin_code, altitude, altitude_accuracy, altitude_method_code, altitude_method_name, vertical_datum, vertical_datum_name, horizontal_positional_accuracy_code, horizontal_positional_accuracy, horizontal_position_method_code, horizontal_position_method_name, original_horizontal_datum, original_horizontal_datum_name, drainage_area, contributing_drainage_area, time_zone_abbreviation, uses_daylight_savings, construction_date, aquifer_code, national_aquifer_code, aquifer_type_code, well_constructed_depth, hole_constructed_depth, depth_source_code, field_measurement_id, unit_of_measure, parameter_name, parameter_code, statistic_id, last_modified, begin, end, data_type, computation_identifier, thresholds, sublocation_identifier, primary, web_description, parameter_description, parent_time_series_id. +geometry, monitoring_location_id, agency_code, agency_name, monitoring_location_number, monitoring_location_name, district_code, country_code, country_name, state_code, state_name, county_code, county_name, minor_civil_division_code, site_type_code, site_type, hydrologic_unit_code, basin_code, altitude, altitude_accuracy, altitude_method_code, altitude_method_name, vertical_datum, vertical_datum_name, horizontal_positional_accuracy_code, horizontal_positional_accuracy, horizontal_position_method_code, horizontal_position_method_name, original_horizontal_datum, original_horizontal_datum_name, drainage_area, contributing_drainage_area, time_zone_abbreviation, uses_daylight_savings, construction_date, aquifer_code, national_aquifer_code, aquifer_type_code, well_constructed_depth, hole_constructed_depth, depth_source_code, field_measurement_id, unit_of_measure, parameter_name, parameter_code, statistic_id, last_modified, begin, end, data_type, computation_identifier, thresholds, sublocation_identifier, primary, web_description, parameter_description, parent_time_series_id, data_gap_interval, reading_type. The default (\code{NA}) will return all columns of the data.} \item{skipGeometry}{This parameter can be used to skip response geometries for @@ -252,7 +252,7 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments +\item{\dots}{Not used. Included to help differentiate official Water Data API arguments from more seldom used, optional dataRetrieval-specific arguments.} \item{convertType}{logical, defaults to TRUE. diff --git a/man/read_waterdata_continuous.Rd b/man/read_waterdata_continuous.Rd index b35db8666..53035a4d3 100644 --- a/man/read_waterdata_continuous.Rd +++ b/man/read_waterdata_continuous.Rd @@ -15,6 +15,8 @@ read_waterdata_continuous( value = NA, last_modified = NA_character_, time = NA_character_, + skipGeometry = TRUE, + bbox = NA, ..., convertType = getOption("dataRetrieval.convertType"), limit = getOption("dataRetrieval.limit"), @@ -34,7 +36,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, continuous_id, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. +geometry, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint. @@ -76,8 +78,22 @@ Only features that have a \code{time} that intersects the value of datetime are See also Details below for more information.} -\item{\dots}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} +\item{skipGeometry}{This parameter can be used to skip response geometries for +each feature. The returning object will be a data frame with no spatial +information. The default \code{NA} will not specify the argument in the request.} + +\item{bbox}{Only features that have a geometry that intersects the bounding +box are selected.The bounding box is provided as four or six numbers, depending +on whether the coordinate reference system includes a vertical axis (height or +depth). Coordinates are assumed to be in crs 4326. The expected format is a numeric +vector structured: c(xmin,ymin,xmax,ymax). +Another way to think of it is c(Western-most longitude, +Southern-most latitude, Eastern-most longitude, Northern-most longitude).} + +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} \item{convertType}{logical, defaults to TRUE. If \code{TRUE}, the function will convert the data to dates, any qualifiers to string @@ -113,9 +129,7 @@ Currently, the services only allow up to 3 years of data to be requested with 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. - -Geometry output is not supported in the continuous data API endpoint. +in 2027. } \details{ You can also use a vector of length 2 for any time queries (such as time @@ -158,6 +172,12 @@ multi_site2 <- read_waterdata_continuous(monitoring_location_id = c("USGS-45160 parameter_code = c("00060", "72019"), last_modified = "P7D") +dane <- read_waterdata_continuous( + state_name = "Wisconsin", + county_name = "Dane County", + parameter_code = "00060", + time = "P1D") + # how to split up request into roughly 3 year chunks site <- "USGS-0208458892" @@ -193,3 +213,6 @@ time_df <- data.frame(start = time_chunks[-length(time_chunks)], } \dontshow{\}) # examplesIf} } +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_daily.Rd b/man/read_waterdata_daily.Rd index ef3d7eede..4e982ca9c 100644 --- a/man/read_waterdata_daily.Rd +++ b/man/read_waterdata_daily.Rd @@ -41,7 +41,7 @@ Multiple statistic_ids can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, daily_id, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. +geometry, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint. @@ -95,8 +95,10 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} \item{convertType}{logical, defaults to TRUE. If \code{TRUE}, the function will convert the data to dates, any qualifiers to string @@ -187,6 +189,16 @@ options("dataRetrieval.attach_request" = FALSE) dv_data_no_request <- read_waterdata_daily(monitoring_location_id = site, parameter_code = "00060", time = c("2021-01-01", "2022-01-01")) + +dv_dane <- read_waterdata_daily( + state_name = "Wisconsin", + county_name = "Dane County", + parameter_code = "00060", + time = "P7D") + } \dontshow{\}) # examplesIf} } +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_field_measurements.Rd b/man/read_waterdata_field_measurements.Rd index b9543526c..2565e2dcf 100644 --- a/man/read_waterdata_field_measurements.Rd +++ b/man/read_waterdata_field_measurements.Rd @@ -45,7 +45,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, field_measurement_id, field_measurements_series_id, field_visit_id, parameter_code, monitoring_location_id, observing_procedure_code, observing_procedure, value, unit_of_measure, time, qualifier, vertical_datum, approval_status, measuring_agency, last_modified, control_condition, measurement_rated. +geometry, field_measurements_series_id, reading_type, field_visit_id, parameter_code, monitoring_location_id, observing_procedure_code, observing_procedure, value, unit_of_measure, time, qualifier, vertical_datum, approval_status, measuring_agency, last_modified, control_condition, measurement_rated, year, month, day, time_of_day. The default (\code{NA}) will return all columns of the data.} \item{field_visit_id}{A universally unique identifier (UUID) for the field visit. Multiple measurements may be made during a single field visit.} @@ -118,8 +118,10 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} \item{convertType}{logical, defaults to TRUE. If \code{TRUE}, the function will convert the data to dates, any qualifiers to string @@ -206,7 +208,16 @@ surface_water <- read_waterdata_field_measurements( time = "2024-07-01T00:00:00Z/..", parameter_code = "00060") +dane <- read_waterdata_field_measurements( + state_name = "Wisconsin", + county_name = "Dane County", + parameter_code = "00060", + time = "P30D") + } \dontshow{\}) # examplesIf} } +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_field_meta.Rd b/man/read_waterdata_field_meta.Rd index 1ecfe588f..9047ae656 100644 --- a/man/read_waterdata_field_meta.Rd +++ b/man/read_waterdata_field_meta.Rd @@ -83,7 +83,7 @@ See also Details below for more information.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, field_measurement_id, monitoring_location_id, parameter_code, parameter_name, parameter_description, begin, end, last_modified. +geometry, field_measurement_id, reading_type, monitoring_location_id, parameter_code, parameter_name, parameter_description, begin, end, last_modified. The default (\code{NA}) will return all columns of the data.} \item{skipGeometry}{This parameter can be used to skip response geometries for @@ -104,7 +104,7 @@ limit is 50,000. It may be beneficial to set this number lower if your internet connection is spotty. The default (\code{NA}) will set the limit to the maximum allowable limit for the service.} -\item{...}{Not used. Included to help differentiate official Water Data API arguments +\item{\dots}{Not used. Included to help differentiate official Water Data API arguments from more seldom used, optional dataRetrieval-specific arguments.} \item{convertType}{logical, defaults to TRUE. diff --git a/man/read_waterdata_latest_continuous.Rd b/man/read_waterdata_latest_continuous.Rd index e980a60e6..8921a917a 100644 --- a/man/read_waterdata_latest_continuous.Rd +++ b/man/read_waterdata_latest_continuous.Rd @@ -36,7 +36,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, latest_continuous_id, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. +geometry, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint. @@ -90,8 +90,10 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} \item{convertType}{logical, defaults to TRUE. If \code{TRUE}, the function will convert the data to dates, any qualifiers to string @@ -173,6 +175,15 @@ multi_site2 <- read_waterdata_latest_continuous(monitoring_location_id = c("USG parameter_code = c("00060", "72019"), last_modified = "P7D") +dane <- read_waterdata_latest_continuous( + state_name = "Wisconsin", + county_name = "Dane County", + parameter_code = "00060", + time = "P1D") + } \dontshow{\}) # examplesIf} } +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_latest_daily.Rd b/man/read_waterdata_latest_daily.Rd index 6eb5a386b..2ac341a0a 100644 --- a/man/read_waterdata_latest_daily.Rd +++ b/man/read_waterdata_latest_daily.Rd @@ -41,7 +41,7 @@ Multiple statistic_ids can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, latest_daily_id, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. +geometry, time_series_id, monitoring_location_id, parameter_code, statistic_id, time, value, unit_of_measure, approval_status, qualifier, last_modified. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint. @@ -95,8 +95,10 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} \item{convertType}{logical, defaults to TRUE. If \code{TRUE}, the function will convert the data to dates, any qualifiers to string @@ -171,6 +173,15 @@ multi_site <- read_waterdata_latest_daily(monitoring_location_id = c("USGS-0149 "USGS-01645000"), parameter_code = c("00060", "00010")) +dane <- read_waterdata_latest_daily( + state_name = "Wisconsin", + county_name = "Dane County", + parameter_code = "00060", + time = "P7D") + } \dontshow{\}) # examplesIf} } +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_latest_field_measurements.Rd b/man/read_waterdata_latest_field_measurements.Rd new file mode 100644 index 000000000..1c541ad5e --- /dev/null +++ b/man/read_waterdata_latest_field_measurements.Rd @@ -0,0 +1,174 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read_waterdata_latest_field.R +\name{read_waterdata_latest_field_measurements} +\alias{read_waterdata_latest_field_measurements} +\title{Get Latest USGS Field Measurement Data} +\usage{ +read_waterdata_latest_field_measurements( + monitoring_location_id = NA_character_, + parameter_code = NA_character_, + statistic_id = NA_character_, + properties = NA_character_, + time_series_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, + ..., + convertType = getOption("dataRetrieval.convertType"), + no_paging = getOption("dataRetrieval.no_paging"), + limit = getOption("dataRetrieval.limit"), + chunk_size = getOption("dataRetrieval.site_chunk_size_meta"), + attach_request = getOption("dataRetrieval.attach_request") +) +} +\arguments{ +\item{monitoring_location_id}{A unique identifier representing a single monitoring location. This corresponds to the \code{id} field in the \code{monitoring-locations} endpoint. Monitoring location IDs are created by combining the agency code of the agency responsible for the monitoring location (e.g. USGS) with the ID number of the monitoring location (e.g. 02238500), separated by a hyphen (e.g. USGS-02238500). + +Multiple monitoring_location_ids can be requested as a character vector.} + +\item{parameter_code}{Parameter codes are 5-digit codes used to identify the constituent measured and the units of measure. A complete list of parameter codes and associated groupings can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/parameter-codes/items}. + +Multiple parameter_codes can be requested as a character vector.} + +\item{statistic_id}{Multiple statistic_ids can be requested as a character vector.} + +\item{properties}{A vector of requested columns to be returned from the query. +Available options are: +geometry, field_measurements_series_id, field_visit_id, parameter_code, monitoring_location_id, observing_procedure_code, observing_procedure, value, unit_of_measure, time, qualifier, vertical_datum, approval_status, measuring_agency, last_modified, control_condition, measurement_rated, year, month, day, time_of_day. +The default (\code{NA}) will return all columns of the data.} + +\item{time_series_id}{Multiple time_series_ids can be requested as a character vector.} + +\item{approval_status}{Some of the data that you have obtained from this U.S. Geological Survey database may not have received Director's approval. Any such data values are qualified as provisional and are subject to revision. Provisional data are released on the condition that neither the USGS nor the United States Government may be held liable for any damages resulting from its use. This field reflects the approval status of each record, and is either "Approved", meaining processing review has been completed and the data is approved for publication, or "Provisional" and subject to revision. For more information about provisional data, go to \url{https://waterdata.usgs.gov/provisional-data-statement/}.} + +\item{unit_of_measure}{A human-readable description of the units of measurement associated with an observation.} + +\item{qualifier}{This field indicates any qualifiers associated with an observation, for instance if a sensor may have been impacted by ice or if values were estimated.} + +\item{value}{The value of the observation. Values are transmitted as strings in the JSON response format in order to preserve precision.} + +\item{last_modified}{The last time a record was refreshed in our database. This may happen due to regular operational processes and does not necessarily indicate anything about the measurement has changed. +You can query this field using date-times or intervals, adhering to RFC 3339, or using ISO 8601 duration objects. Intervals may be bounded or half-bounded (double-dots at start or end). +Examples: +\itemize{ +\item A date-time: "2018-02-12T23:20:50Z" +\item A bounded interval: "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z" +\item Half-bounded intervals: "2018-02-12T00:00:00Z/.." or "../2018-03-18T12:31:12Z" +\item Duration objects: "P1M" for data from the past month or "PT36H" for the last 36 hours +} + +Only features that have a \code{last_modified} that intersects the value of datetime are selected. + +See also Details below for more information.} + +\item{skipGeometry}{This parameter can be used to skip response geometries for +each feature. The returning object will be a data frame with no spatial +information. The default \code{NA} will not specify the argument in the request.} + +\item{time}{The date an observation represents. You can query this field using date-times or intervals, adhering to RFC 3339, or using ISO 8601 duration objects. Intervals may be bounded or half-bounded (double-dots at start or end). +Examples: +\itemize{ +\item A date-time: "2018-02-12T23:20:50Z" +\item A bounded interval: "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z" +\item Half-bounded intervals: "2018-02-12T00:00:00Z/.." or "../2018-03-18T12:31:12Z" +\item Duration objects: "P1M" for data from the past month or "PT36H" for the last 36 hours +} + +Only features that have a \code{time} that intersects the value of datetime are selected. If a feature has multiple temporal properties, it is the decision of the server whether only a single temporal property is used to determine the extent or all relevant temporal properties. + +See also Details below for more information.} + +\item{bbox}{Only features that have a geometry that intersects the bounding +box are selected.The bounding box is provided as four or six numbers, depending +on whether the coordinate reference system includes a vertical axis (height or +depth). Coordinates are assumed to be in crs 4326. The expected format is a numeric +vector structured: c(xmin,ymin,xmax,ymax). +Another way to think of it is c(Western-most longitude, +Southern-most latitude, Eastern-most longitude, Northern-most longitude).} + +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} + +\item{convertType}{logical, defaults to TRUE. +If \code{TRUE}, the function will convert the data to dates, any qualifiers to string +vector and reorder the returned data frame.} + +\item{no_paging}{logical, defaults to FALSE. +If \code{TRUE}, the data will +be requested from a native csv format. This can be dangerous because the +data will cut off at 50,000 rows without indication that more data +is available. Use \code{TRUE} with caution.} + +\item{limit}{numeric, 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 50,000. It may be beneficial to set this number lower if your internet +connection is spotty. The default (\code{NA}) will set the limit to the maximum +allowable limit for the service.} + +\item{chunk_size}{Number of monitoring_location_ids to chunk requests into. +The default for functions that don't generally return long-term data records +is 250, while +the default for time series functions is +10. +Setting to \code{NA} will eliminate site chunking, giving users full control.} + +\item{attach_request}{logical, defaults to TRUE. +If set to \code{TRUE}, the full request sent to the Water Data API is attached +as an attribute to the data set.} +} +\description{ +Field measurements are physically measured values collected during a visit to the monitoring location. Field measurements consist of measurements of gage height and discharge, and readings of groundwater levels, and are primarily used as calibration readings for the automated sensors collecting continuous data. They are collected at a low frequency, and delivery of the data in WDFN may be delayed due to data processing time. +} +\details{ +You can also use a vector of length 2 for any time queries (such as time +or last_modified). The first value is the starting date (or datetime), +the second value is the ending date(or datetime). +NA's within the vector indicate a half-bound date. +For example, \code{time = c("2024-01-01", NA)} will return all data starting +at 2024-01-01. +\code{time = c(NA, "2024-01-01")} will return all data from the beginning of +the timeseries until 2024-01-01. +By default, time is assumed UTC, although time zone attributes +will be accommodated. As an example, setting \code{time = as.POSIXct(c("2021-01-01 12:00:00", +"2021-01-01 14:00"), tz = "America/New_York")} will request data that between +noon and 2pm eastern time on 2021-01-01. +All time values RETURNED from the service are UTC with the exception of +daily data, which returns time values in local dates. +} +\examples{ +\dontshow{if (is_dataRetrieval_user()) withAutoprint(\{ # examplesIf} + +\donttest{ +site <- "USGS-01435000" + +field_data_sf <- read_waterdata_latest_field_measurements(monitoring_location_id = site) + +dv_data_trim <- read_waterdata_latest_field_measurements(monitoring_location_id = site, + properties = c("monitoring_location_id", + "value", + "time")) + +field_data <- read_waterdata_latest_field_measurements(monitoring_location_id = site, + skipGeometry = TRUE) + +multi_site <- read_waterdata_latest_field_measurements(monitoring_location_id = c("USGS-01435000", + "USGS-14202650")) + +dane <- read_waterdata_latest_field_measurements( + state_name = "Wisconsin", + county_name = "Dane County", + time = "P30D") + +} +\dontshow{\}) # examplesIf} +} +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_monitoring_location.Rd b/man/read_waterdata_monitoring_location.Rd index 5072a644f..ee2b32f76 100644 --- a/man/read_waterdata_monitoring_location.Rd +++ b/man/read_waterdata_monitoring_location.Rd @@ -45,7 +45,11 @@ read_waterdata_monitoring_location( well_constructed_depth = NA_character_, hole_constructed_depth = NA_character_, depth_source_code = NA_character_, + revision_note = NA_character_, + revision_created = NA_character_, + revision_modified = NA_character_, properties = NA_character_, + q = NA_character_, bbox = NA, skipGeometry = NA, ..., @@ -88,7 +92,7 @@ Multiple monitoring_location_ids can be requested as a character vector.} \item{site_type}{A description of the hydrologic setting of the monitoring location. A list of codes is available at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/site-types/items}.} -\item{hydrologic_unit_code}{The United States is divided and sub-divided into successively smaller hydrologic units which are classified into four levels: regions, sub-regions, accounting units, and cataloging units. The hydrologic units are arranged within each other, from the smallest (cataloging units) to the largest (regions). Each hydrologic unit is identified by a unique hydrologic unit code (HUC) consisting of two to eight digits based on the four levels of classification in the hydrologic unit system.} +\item{hydrologic_unit_code}{The hydrologic unit code (HUC) for the monitoring location. Supports prefix matching — querying with a shorter HUC (e.g. "04") matches all locations within that hydrologic region.} \item{basin_code}{The Basin Code or "drainage basin code" is a two-digit code that further subdivides the 8-digit hydrologic-unit code. The drainage basin code is defined by the USGS State Office where the monitoring location is located.} @@ -138,11 +142,31 @@ Multiple monitoring_location_ids can be requested as a character vector.} \item{depth_source_code}{A code indicating the source of water-level data.} +\item{revision_note}{Approved water data are considered published record, but on occasion changes or deletions (revisions) must be made to data after they are approved. Data revisions are rare because of USGS quality assurance practices, including documentation of all data before they are officially approved. This field contains text explanations for data revisions at this monitoring location. Changes to data also are indicated with revision qualifier codes alongside the data. Text explanations before 2017 are not necessarily available online, but can be requested.} + +\item{revision_created}{The date a revision statement was created.} + +\item{revision_modified}{The most recent date a revision statement was modified.} + \item{properties}{A vector of requested columns to be returned from the query. Available options are: geometry, monitoring_location_id, agency_code, agency_name, monitoring_location_number, monitoring_location_name, district_code, country_code, country_name, state_code, state_name, county_code, county_name, minor_civil_division_code, site_type_code, site_type, hydrologic_unit_code, basin_code, altitude, altitude_accuracy, altitude_method_code, altitude_method_name, vertical_datum, vertical_datum_name, horizontal_positional_accuracy_code, horizontal_positional_accuracy, horizontal_position_method_code, horizontal_position_method_name, original_horizontal_datum, original_horizontal_datum_name, drainage_area, contributing_drainage_area, time_zone_abbreviation, uses_daylight_savings, construction_date, aquifer_code, national_aquifer_code, aquifer_type_code, well_constructed_depth, hole_constructed_depth, depth_source_code, revision_note, revision_created, revision_modified. The default (\code{NA}) will return all columns of the data.} +\item{q}{Full-text search across the most relevant text fields for this collection +(e.g. site name, identifier, number, state, county, and site type). +Matching rules: +\itemize{ +\item Case-insensitive, with prefix matching (e.g. poud matches POUDRE). +\item Words separated by spaces are AND'd together (all must match). +\item Terms separated by commas are OR'd together (any may match). +\item Common abbreviations are expanded, so river also matches sites stored as RV (and vice versa). +Examples are: +q=poudre - sites whose name/identifier starts with or contains poudre +q=colorado river - sites matching both colorado and river/rv +q=poudre,cache creek - sites matching poudre OR (cache AND creek/ck) +}} + \item{bbox}{Only features that have a geometry that intersects the bounding box are selected.The bounding box is provided as four or six numbers, depending on whether the coordinate reference system includes a vertical axis (height or @@ -155,7 +179,7 @@ Southern-most latitude, Eastern-most longitude, Northern-most longitude).} each feature. The returning object will be a data frame with no spatial information. The default \code{NA} will not specify the argument in the request.} -\item{...}{Not used. Included to help differentiate official Water Data API arguments +\item{\dots}{Not used. Included to help differentiate official Water Data API arguments from more seldom used, optional dataRetrieval-specific arguments.} \item{limit}{numeric, The optional limit parameter is used to control the subset of the @@ -215,6 +239,7 @@ site_info_no_sf <- read_waterdata_monitoring_location( bbox_vals = c(-94.00, 35.0, -93.5, 35.5) multi_site <- read_waterdata_monitoring_location(bbox = bbox_vals) +poudre <- read_waterdata_monitoring_location(q = "poudre") } \dontshow{\}) # examplesIf} diff --git a/man/read_waterdata_peaks.Rd b/man/read_waterdata_peaks.Rd index 79e98b2c2..42b25d0e7 100644 --- a/man/read_waterdata_peaks.Rd +++ b/man/read_waterdata_peaks.Rd @@ -18,6 +18,7 @@ read_waterdata_peaks( day = NA_character_, time_of_day = NA_character_, peak_since = NA_character_, + qualifier = NA_character_, skipGeometry = NA, time = NA_character_, bbox = NA, @@ -41,7 +42,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, time_series_id, monitoring_location_id, parameter_code, peak_id, unit_of_measure, value, last_modified, time, water_year, year, month, day, time_of_day, peak_since. +geometry, time_series_id, monitoring_location_id, parameter_code, unit_of_measure, value, last_modified, time, water_year, year, month, day, time_of_day, peak_since, qualifier. The default (\code{NA}) will return all columns of the data.} \item{time_series_id}{A unique identifier representing a single time series. This corresponds to the \code{id} field in the \code{time-series-metadata} endpoint.} @@ -76,6 +77,8 @@ See also Details below for more information.} \item{peak_since}{If not null, this record represents the peak value for the parameter code since the year contained in "peak_since".} +\item{qualifier}{This field indicates any qualifiers associated with an observation, for instance if a sensor may have been impacted by ice or if values were estimated.} + \item{skipGeometry}{This parameter can be used to skip response geometries for each feature. The returning object will be a data frame with no spatial information. The default \code{NA} will not specify the argument in the request.} @@ -101,8 +104,10 @@ vector structured: c(xmin,ymin,xmax,ymax). Another way to think of it is c(Western-most longitude, Southern-most latitude, Eastern-most longitude, Northern-most longitude).} -\item{...}{Not used. Included to help differentiate official Water Data API arguments -from more seldom used, optional dataRetrieval-specific arguments.} +\item{\dots}{Arguments that can be queried, +but are not returned. These are used as alternatives to specifying specific +monitoring_location_ids. See \code{?get_monitoring_location_arguments} +for available arguments.} \item{allow_incomplete_dates}{Specifically in the peaks data, exact peak dates are not always known. Sometimes peaks are known just for the year, sometimes @@ -173,6 +178,11 @@ dv_data_sf <- read_waterdata_peaks( monitoring_location_id = wi_peaks$monitoring_location_id[1], parameter_code = "00060") +dane <- read_waterdata_peaks( + state_name = "Wisconsin", + county_name = "Dane County", + parameter_code = "00060") + incomplete_dates_not_allowed <- read_waterdata_peaks( monitoring_location_id = "USGS-06334330", parameter_code = "00060") @@ -186,3 +196,6 @@ incomplete_dates_allowed$time } \dontshow{\}) # examplesIf} } +\seealso{ +\code{\link[=get_monitoring_location_arguments]{get_monitoring_location_arguments()}} +} diff --git a/man/read_waterdata_ratings.Rd b/man/read_waterdata_ratings.Rd index 4b516e345..c883e0af5 100644 --- a/man/read_waterdata_ratings.Rd +++ b/man/read_waterdata_ratings.Rd @@ -57,7 +57,13 @@ and return a list of data frames with rating curve data (\code{TRUE}), or to ret just a list of available rating curve files (\code{FALSE}). Default is \code{TRUE}.} } \value{ -List of data frames which contain the requested rating curves. +List of named lists, one per requested rating file. Each element +contains: +\describe{ +\item{ratings}{Data frame of the rating curve.} +\item{metadata}{Data frame of header/value pairs parsed from the comment +attribute of the ratings file.} +} } \description{ Reads current rating table for an active USGS streamgages. More information @@ -89,20 +95,24 @@ ratings_exsa <- read_waterdata_ratings( monitoring_location_id = monitoring_location_id, file_type = "exsa") -head(ratings_exsa[["USGS-01104475.exsa.rdb"]]) -comment(ratings_exsa[["USGS-01104475.exsa.rdb"]])[1:15] +head(ratings_exsa[["USGS-01104475.exsa.rdb"]]$ratings) +m1 <- ratings_exsa[["USGS-01104475.exsa.rdb"]]$metadata +m1 ratings_corr <- read_waterdata_ratings( monitoring_location_id = monitoring_location_id, file_type = "corr") -head(ratings_corr[["USGS-01104460.corr.rdb"]]) -comment(ratings_corr[["USGS-01104460.corr.rdb"]])[1:15] +head(ratings_corr[["USGS-01104460.corr.rdb"]]$ratings) +m2 <- ratings_corr[["USGS-01104460.corr.rdb"]]$metadata +m2 rating_2 <- read_waterdata_ratings( monitoring_location_id = monitoring_location_id, file_type = c("corr", "exsa")) names(rating_2) +m3 <- rating_2$`USGS-01104460.exsa.rdb`$metadata +rat_data <- rating_2$`USGS-01104460.exsa.rdb`$ratings bbox <- c(-95.00, 40.0, -92.0, 42) @@ -112,7 +122,6 @@ length(bbox_query) recent_query <- read_waterdata_ratings(bbox = bbox, datetime = c(Sys.Date()-7, NA), download_and_parse = FALSE) -length(recent_query) } \dontshow{\}) # examplesIf} } diff --git a/man/read_waterdata_ts_meta.Rd b/man/read_waterdata_ts_meta.Rd index 3188d4b8b..fd381a2fe 100644 --- a/man/read_waterdata_ts_meta.Rd +++ b/man/read_waterdata_ts_meta.Rd @@ -49,7 +49,7 @@ Multiple parameter_codes can be requested as a character vector.} \item{properties}{A vector of requested columns to be returned from the query. Available options are: -geometry, time_series_id, unit_of_measure, parameter_name, parameter_code, statistic_id, hydrologic_unit_code, state_name, last_modified, begin, end, begin_utc, end_utc, computation_period_identifier, computation_identifier, thresholds, sublocation_identifier, primary, monitoring_location_id, web_description, parameter_description, parent_time_series_id. +geometry, time_series_id, unit_of_measure, parameter_name, parameter_code, statistic_id, hydrologic_unit_code, state_name, last_modified, begin, end, begin_utc, end_utc, computation_period_identifier, computation_identifier, thresholds, sublocation_identifier, primary, monitoring_location_id, web_description, parameter_description, parent_time_series_id, data_gap_interval. The default (\code{NA}) will return all columns of the data.} \item{statistic_id}{A code corresponding to the statistic an observation represents. Example codes include 00001 (max), 00002 (min), and 00003 (mean). A complete list of codes and their descriptions can be found at \url{https://api.waterdata.usgs.gov/ogcapi/v0/collections/statistic-codes/items}. @@ -99,7 +99,7 @@ Only features that have a \code{end_utc} that intersects the value of datetime a See also Details below for more information.} -\item{hydrologic_unit_code}{The United States is divided and sub-divided into successively smaller hydrologic units which are classified into four levels: regions, sub-regions, accounting units, and cataloging units. The hydrologic units are arranged within each other, from the smallest (cataloging units) to the largest (regions). Each hydrologic unit is identified by a unique hydrologic unit code (HUC) consisting of two to eight digits based on the four levels of classification in the hydrologic unit system.} +\item{hydrologic_unit_code}{The hydrologic unit code (HUC) for the monitoring location. Supports prefix matching — querying with a shorter HUC (e.g. "04") matches all locations within that hydrologic region.} \item{state_name}{The name of the state or state equivalent in which the monitoring location is located.} @@ -145,7 +145,7 @@ Southern-most latitude, Eastern-most longitude, Northern-most longitude).} \item{end}{This field contains the same information as "end_utc", but in the local time of the monitoring location. It is retained for backwards compatibility, but will be removed in V1 of these APIs.} -\item{...}{Not used. Included to help differentiate official Water Data API arguments +\item{\dots}{Not used. Included to help differentiate official Water Data API arguments from more seldom used, optional dataRetrieval-specific arguments.} \item{limit}{numeric, The optional limit parameter is used to control the subset of the diff --git a/tests/testthat/test_ngwmn.R b/tests/testthat/test_ngwmn.R new file mode 100644 index 000000000..1c6256851 --- /dev/null +++ b/tests/testthat/test_ngwmn.R @@ -0,0 +1,76 @@ +context("NGWMN functions") + +test_that("NGWMN retrievals working", { + testthat::skip_on_cran() + testthat::skip_on_ci() + + cql <- '{ + "op": "between", + "args": [ + { "property": "water_level_above_navd88_ft" }, + [ "100.00", "200.00" ] + ] +}' + + wl_data <- read_ngwmn(service = "waterLevelObs", + monitoring_location_id = c("USGS-272838082142201", + "USGS-404159100494601", + "USGS-401216080362703"), + CQL = cql) + + # no CQL should work too: + wl_data_full <- read_ngwmn(service = "waterLevelObs", + monitoring_location_id = c("USGS-272838082142201", + "USGS-404159100494601", + "USGS-401216080362703")) + + cql3 <- '{ + "op": "and", + "args": [ + { + "op": "between", + "args": [ + { "property": "water_level_above_navd88_ft" }, + [ "100.00", "200.00" ] + ] + }, + { + "op": "in", + "args": [ + { "property": "monitoring_location_id" }, + [ "USGS-272838082142201", "USGS-404159100494601", "USGS-401216080362703" ] + ] + } + ] + }' + + + wl_data_alt <- read_ngwmn(service = "waterLevelObs", + CQL = cql3) + + expect_equal(nrow(wl_data_alt), nrow(wl_data)) + expect_gt(nrow(wl_data_full), nrow(wl_data)) + + sites <- c("ISWS-P428197", + "AKDNR-535143966816631", + "AKDNR-535134236016630") + ngwml_lith_sites <- read_ngwmn_lithology(monitoring_location_id = sites) + expect_all_true(c("ISWS", "AKDNR") %in% unique(ngwml_lith_sites$agency_code)) + + org_type <- read_ngwmn_sites(agency_code = "MN_DNR", + county_name = "Washington County") + expect_true("MN_DNR" == unique(org_type$agency_code)) + + site <- "USGS-272838082142201" + + ngwml_wl_time2 <- read_ngwmn_water_level(monitoring_location_id = site, + datetime = c("2022-01-01", "2024-01-01")) + expect_true(min(as.Date(ngwml_wl_time2$sample_time)) >= as.Date("2022-01-01")) + expect_true(max(as.Date(ngwml_wl_time2$sample_time)) <= as.Date("2024-01-01")) + + sites <- c("USGS-272838082142201", "USGS-404159100494601", + "USGS-401216080362703", "MBMG-702934") + ngwml_well_sites <- read_ngwmn_well_construction(monitoring_location_id = sites) + + expect_all_true(unique(ngwml_well_sites$monitoring_location_id) %in% sites) +}) diff --git a/tests/testthat/tests_general.R b/tests/testthat/tests_general.R index f0830ffa9..54cbbd284 100644 --- a/tests/testthat/tests_general.R +++ b/tests/testthat/tests_general.R @@ -164,7 +164,7 @@ test_that("General NWIS retrievals working", { expect_equal(names(rating_curve), "USGS-01594440.base.rdb") state_rating_list <- read_waterdata_ratings( - datetime = c(Sys.Date() - 1, NA), + datetime = c(Sys.Date() - 1, as.Date(NA)), download_and_parse = FALSE ) diff --git a/tests/testthat/tests_userFriendly_fxns.R b/tests/testthat/tests_userFriendly_fxns.R index 393c13b4b..23215ed97 100644 --- a/tests/testthat/tests_userFriendly_fxns.R +++ b/tests/testthat/tests_userFriendly_fxns.R @@ -123,11 +123,24 @@ test_that("peak, rating curves, surface-water measurements", { monitoring_location_id = siteNumber, file_type = "base" ) - expect_gt(length(comment(data[[1]])), 1) + expect_type(data, "list") + expect_length(data, 1) + + sub <- data[[1]] + expect_type(sub, "list") + expect_setequal(names(sub), c("ratings", "metadata")) # Surface meas: siteNumbers <- c("USGS-01594440", "USGS-040851325") - data <- read_waterdata_field_measurements(siteNumbers) + data <- read_waterdata_field_measurements( + monitoring_location_id = siteNumbers + ) + expect_is(data$monitoring_location_id, "character") + + # Latest Surface meas: + latest_data <- read_waterdata_latest_field_measurements( + monitoring_location_id = siteNumbers + ) expect_is(data$monitoring_location_id, "character") siteINFO_USGS <- read_waterdata_monitoring_location( @@ -169,13 +182,12 @@ test_that("peak, rating curves, surface-water measurements", { expect_equal(unique(gwl_1$monitoring_location_id), siteID) # No data: - stations <- "06011000" - expect_message(readNWISpeak( - stations, - startDate = "2024-08-01", - endDate = "2024-08-31", - convertType = FALSE - )) + + no_data <- read_waterdata_peaks( + monitoring_location_id = "USGS-06011000", + time = c("2024-08-01", "2024-08-31") + ) + expect_equal(nrow(no_data), 0) }) test_that("read_waterdata_daily", { @@ -260,45 +272,44 @@ test_that("read_waterdata_daily", { # "ICE, REGULATED, UNKNOWNREGULATION")) }) -test_that("WQP qw tests", { - testthat::skip_on_cran() - skip_on_ci() - # nameToUse <- "Specific conductance" - # pcodeToUse <- "00095" - # - # INFO_WQP <- readWQPqw( - # "USGS-04024315", - # pcodeToUse, - # startDate = "", - # endDate = "", - # legacy = FALSE - # ) - # expect_is(INFO_WQP$Activity_StartDateTime, "POSIXct") - # - # INFO2 <- readWQPqw( - # "WIDNR_WQX-10032762", - # nameToUse, - # startDate = "", - # endDate = "", - # legacy = FALSE - # ) - # expect_is(INFO2$Activity_StartDateTime, "POSIXct") - # - # df <- readWQPqw("USGS-04193500", parameterCd = "00665", legacy = FALSE) - # expect_true(nrow(df) > 0) - # - # df2 <- readWQPqw("USGS-05427718", parameterCd = "all") - # expect_true(nrow(df2) > 0) - # - # #Empty legacy: - # df3 <- readWQPqw( - # siteNumbers = "USGS-385032115220501", - # parameterCd = "all", - # legacy = TRUE - # ) - # expect_true(nrow(df3) == 0) -}) - +# test_that("WQP qw tests", { +# testthat::skip_on_cran() +# skip_on_ci() +# nameToUse <- "Specific conductance" +# pcodeToUse <- "00095" +# +# INFO_WQP <- readWQPqw( +# "USGS-04024315", +# pcodeToUse, +# startDate = "", +# endDate = "", +# legacy = FALSE +# ) +# expect_is(INFO_WQP$Activity_StartDateTime, "POSIXct") +# +# INFO2 <- readWQPqw( +# "WIDNR_WQX-10032762", +# nameToUse, +# startDate = "", +# endDate = "", +# legacy = FALSE +# ) +# expect_is(INFO2$Activity_StartDateTime, "POSIXct") +# +# df <- readWQPqw("USGS-04193500", parameterCd = "00665", legacy = FALSE) +# expect_true(nrow(df) > 0) +# +# df2 <- readWQPqw("USGS-05427718", parameterCd = "all") +# expect_true(nrow(df2) > 0) +# +# #Empty legacy: +# df3 <- readWQPqw( +# siteNumbers = "USGS-385032115220501", +# parameterCd = "all", +# legacy = TRUE +# ) +# expect_true(nrow(df3) == 0) +# }) context("state tests") test_that("state county tests", { diff --git a/tutorials/basic_slides_deck.qmd b/tutorials/basic_slides_deck.qmd index ab03fbcb8..05002d31d 100644 --- a/tutorials/basic_slides_deck.qmd +++ b/tutorials/basic_slides_deck.qmd @@ -8,7 +8,6 @@ format: toc: false slide-number: true logo: hex_logo.png - footer: preview-links: auto title-slide-attributes: data-background-image: combo_hex.png @@ -29,6 +28,8 @@ params: run_python: true --- + + ```{r} #| echo: false #| include: false diff --git a/vignettes/Status.Rmd b/vignettes/Status.Rmd index f6aab2006..30781563a 100644 --- a/vignettes/Status.Rmd +++ b/vignettes/Status.Rmd @@ -181,9 +181,6 @@ Currently, any "qw" data summaries provided by `whatNWISdata` are very likely ou ## National Groundwater Monitoring Network -Coming soon, a new new access point for the National Groundwater Monitoring Network. The original `readNGWMNdata` functions have been broken for some time. Stay tuned! - - - +A new access point for the National Groundwater Monitoring Network. The original `readNGWMNdata` functions have been broken for some time, the `read_ngwmn` set of functions are now available to access this data. diff --git a/vignettes/dataRetrieval.Rmd b/vignettes/dataRetrieval.Rmd index d5b3c69ca..4614fe95b 100644 --- a/vignettes/dataRetrieval.Rmd +++ b/vignettes/dataRetrieval.Rmd @@ -681,4 +681,3 @@ Water Quality Portal. Washington (DC): National Water Quality Monitoring Council # Disclaimer This information is preliminary and is subject to revision. It is being provided to meet the need for timely best science. The information is provided on the condition that neither the U.S. Geological Survey nor the U.S. Government may be held liable for any damages resulting from the authorized or unauthorized use of the information. - diff --git a/vignettes/read_waterdata_functions.Rmd b/vignettes/read_waterdata_functions.Rmd index cb2e94cfa..28fa03211 100644 --- a/vignettes/read_waterdata_functions.Rmd +++ b/vignettes/read_waterdata_functions.Rmd @@ -77,9 +77,9 @@ API_USGS_PAT = "my_super_secret_token" ``` You can use `usethis::edit_r_environ()` to edit find and open your .Renviron file. You will need to restart R for that variable to be recognized. You should not add this file to git projects or generally share your API key. Anyone else using your API key will count against the number of requests available to you! -## Contextual Query Language Support +## Common Query Language Support -Supports [Contextual Query Language](https://www.loc.gov/standards/sru/cql/) (CQL2) syntax for flexible queries. See the `read_waterdata` section below to learn how to make specific and powerful CQL2 queries. +Supports [Common Query Language](https://www.ogc.org/standards/cql2/) (CQL2) syntax for flexible queries. See the `read_waterdata` section below to learn how to make specific and powerful CQL2 queries. ## Simple Features diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd index e97fa1cf5..3f4900cb9 100644 --- a/vignettes/tutorial.Rmd +++ b/vignettes/tutorial.Rmd @@ -441,9 +441,11 @@ There are two services that also have functions in `dataRetrieval`, the National Similar to WQP, the NGWMN brings groundwater data from multiple sources into a single location. There are currently a few `dataRetrieval` functions included: -* `readNGWMNsites()` -* `readNGWMNlevels()` -* `readNGWMNdata()`. +* `read_ngwmn_sites` +* `read_ngwmn_water_levels` +* `read_ngwmn_providers` +* `read_ngwmn_well_construction` +* `read_ngwmn_lithology` ## Network Linked Data Index (NLDI)