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