diff --git a/DESCRIPTION b/DESCRIPTION index 4e3daa8..6fa9e37 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: NRWgauges Title: Web-scraping gauge (meta-)data from various providers in NRW, Germany -Version: 0.3.5 +Version: 0.3.6 Date: 2024-12-27 Authors@R: person("Dimitri", "Falk", , "falk.dimitri@eglv.de", role = c("aut", "cre")) diff --git a/NAMESPACE b/NAMESPACE index 8826a92..ad47f07 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,4 +3,5 @@ export(get_eglv_gauges) export(get_eglv_measurements) export(get_eglv_meta) +export(get_rv_gauges) export(get_rv_meta) diff --git a/R/get_rv_gauges.R b/R/get_rv_gauges.R new file mode 100644 index 0000000..b5c299c --- /dev/null +++ b/R/get_rv_gauges.R @@ -0,0 +1,40 @@ +#' Get RV gauge metadata (simplified), locations and latest measurements +#' +#' @return Sf object. +#' @export +#' +#' @examples +#' \dontrun{ +#' get_rv_gauges() +#' } +get_rv_gauges <- function() { + + # debugging ------------------------------------------------------------------ + + # check arguments ------------------------------------------------------------ + + # ---------------------------------------------------------------------------- + + base_url <- "https://www.talsperrenleitzentrale-ruhr.de/online-daten/gewaesserpegel/" + + # query definition + query <- list("tx_onlinedata_gauges%5baction%5d" = "json", + "tx_onlinedata_gauges%5bcontroller%5d" = "Gauges", + "type" = "863") + + # send request + r_raw <- httr::GET(base_url, query = query) + + # parse response: raw to json + r_json <- httr::content(r_raw, "text", encoding = "UTF-8") + + gauges <- jsonlite::fromJSON(r_json) |> + tibble::as_tibble() + + # fix columns + gauges[["datetime"]] <- gauges[["datetime"]] |> as.POSIXct(tz = "etc/GMT-1") + + gauges[["value"]] <- gauges[["value"]] |> as.numeric() + + gauges +} diff --git a/man/get_rv_gauges.Rd b/man/get_rv_gauges.Rd new file mode 100644 index 0000000..aa4ed09 --- /dev/null +++ b/man/get_rv_gauges.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_rv_gauges.R +\name{get_rv_gauges} +\alias{get_rv_gauges} +\title{Get RV gauge metadata (simplified), locations and latest measurements} +\usage{ +get_rv_gauges() +} +\value{ +Sf object. +} +\description{ +Get RV gauge metadata (simplified), locations and latest measurements +} +\examples{ +\dontrun{ +get_rv_gauges() +} +}