knitr::opts_chunk$set( collapse = TRUE, comment = "#>" #, eval = FALSE # to temporarily "switch off" this (long running) vignette )
cat_file_enumeration <- function(files) { cat(paste0(collapse = "\n\n", sprintf( "- [%s](%s/%s)", files, "https://kwb-r.github.io/wasserportal", files ))) }
library(wasserportal) stations <- wasserportal::get_stations() stations_list <- kwb.utils::selectElements(stations, "overview_list") is_sw <- stringr::str_detect(names(stations_list), "surface") files <- wasserportal::list_masters_data_to_csv(stations_list[is_sw])
The following surface water master data .csv
files are available for download:
cat_file_enumeration(files)
By running the code below all available daily surface water
data of monitoring
stations from Wasserportal Berlin will be downloaded and exported into one .json
file for each parameter and all available monitoring stations.
variables <- wasserportal::get_surfacewater_variables() variables sw_data_daily_list <- wasserportal::get_daily_surfacewater_data( stations, variables ) files <- wasserportal::list_timeseries_data_to_zip(sw_data_daily_list) files # Data availability per parameter sw_data_daily_list %>% dplyr::bind_rows() %>% dplyr::count(Parameter, Einheit) station_ids <- stations$overview_list$surface_water.quality$Messstellennummer swq_data <- wasserportal::get_surfacewater_qualities(station_ids) files1 <- wasserportal::list_timeseries_data_to_zip( list("surface-water_quality" = swq_data) ) files2 <- "surface-water_quality.zip" file.rename(files1, files2)
The following .zip
files are available for download:
cat_file_enumeration(c(files, files2))
swl_master <- wasserportal::get_wasserportal_masters_data( master_urls = stations_list$surface_water.water_level %>% dplyr::filter(.data$Betreiber == "Land Berlin") %>% dplyr::pull(.data$stammdaten_link) ) column_level_zero <- "Pegelnullpunkt_m_NHN" swl_data <- sw_data_daily_list$surface_water.water_level %>% dplyr::select(where(~!all(is.na(.x)))) %>% dplyr::left_join( kwb.utils::selectColumns(swl_master, c("Nummer", column_level_zero)), by = c(Messstellennummer = "Nummer") ) %>% dplyr::mutate( Tagesmittelwert_Pegelstand_mNN = as.numeric(.data[[column_level_zero]]) + .data$Tagesmittelwert / 100 ) %>% ### remove -777 for messstellennummer 5867000 (few values in 2000) resulted by ### step above dplyr::filter(.data[["Tagesmittelwert_Pegelstand_mNN"]] != -777) %>% kwb.utils::removeColumns(column_level_zero) str(swl_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.