Skip to contents

Stations

General overview

# install.packages("remotes")
# remotes::install_github("kwb-r/wasserportal", upgrade = "never", force = TRUE)
library(wasserportal)
overview_options <- wasserportal::get_overview_options()
str(overview_options)
#> List of 2
#>  $ surface_water:List of 7
#>   ..$ water_level         : chr "ws"
#>   ..$ flow                : chr "df"
#>   ..$ temperature         : chr "wt"
#>   ..$ conductivity        : chr "lf"
#>   ..$ ph                  : chr "ph"
#>   ..$ oxygen_concentration: chr "og"
#>   ..$ oxygen_saturation   : chr "os"
#>  $ groundwater  :List of 2
#>   ..$ level  : chr "gws"
#>   ..$ quality: chr "gwq"

system.time(stations <- wasserportal::get_stations())
#> Importing 9 station overviews from Wasserportal Berlin ... ok. (7.79s)
#>    user  system elapsed 
#>   0.065   0.012   8.108

str(stations)
#> List of 3
#>  $ overview_list:List of 9
#>   ..$ surface_water.water_level         : tibble [75 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: int [1:75] 5865900 5827103 5870400 5865300 5819900 5864801 5861101 5800107 5800317 5867003 ...
#>   .. ..$ Messstellenname  : chr [1:75] "Allee der Kosmonauten" "Allendestraße" "Alsenbrücke" "Am Bahndamm" ...
#>   .. ..$ Gewaesser        : chr [1:75] "M.-H.-Grenzgr." "Müggelspree" "Griebnitzkanal" "Wuhle" ...
#>   .. ..$ Betreiber        : chr [1:75] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:75] "19.10.2022 06:30" "19.10.2022 06:30" "19.10.2022 06:30" "19.10.2022 06:30" ...
#>   .. ..$ Wasserstand      : int [1:75] 23 52 51 101 73 6 21 73 74 84 ...
#>   .. ..$ Einheit          : chr [1:75] "cm" "cm" "cm" "cm" ...
#>   .. ..$ Ganglinien       : logi [1:75] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:75] "normal" "normal" "niedrig" "normal" ...
#>   .. ..$ stammdaten_link  : chr [1:75] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5865900" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5827103" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5870400" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5865300" ...
#>   ..$ surface_water.flow                : tibble [18 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: int [1:18] 5827103 5870400 5865300 5864801 5867401 5867900 5827101 5870100 5826701 5862811 ...
#>   .. ..$ Messstellenname  : chr [1:18] "Allendestraße" "Alsenbrücke" "Am Bahndamm" "Am Kienberg" ...
#>   .. ..$ Gewaesser        : chr [1:18] "Müggelspree" "Griebnitzkanal" "Wuhle" "Hellersdorfer Graben" ...
#>   .. ..$ Betreiber        : chr [1:18] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:18] "01.05.2022 23:45" "" "18.10.2022 23:30" "19.10.2022 06:30" ...
#>   .. ..$ Durchfluss       : num [1:18] 3.29 NA 0.102 0.022 0.384 1.94 1.33 9.14 5.9 6.08 ...
#>   .. ..$ Einheit          : chr [1:18] "m³/s" "m³/s" "m³/s" "m³/s" ...
#>   .. ..$ Ganglinie        : logi [1:18] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:18] "nicht aktuell" "nicht aktuell" "niedrig" "keine" ...
#>   .. ..$ stammdaten_link  : chr [1:18] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=odf&sstation=5827103" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=odf&sstation=5870400" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=odf&sstation=5865300" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=odf&sstation=5864801" ...
#>   ..$ surface_water.temperature         : tibble [64 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:64] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:64] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:64] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:64] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:64] "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" ...
#>   .. ..$ Wassertemperatur : chr [1:64] "14.89" "14.05" "13.87" "13.77" ...
#>   .. ..$ Einheit          : chr [1:64] "°C" "°C" "°C" "°C" ...
#>   .. ..$ Ganglinie        : logi [1:64] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:64] ">10 - 15°C" ">10 - 15°C" ">10 - 15°C" ">10 - 15°C" ...
#>   .. ..$ stammdaten_link  : chr [1:64] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=601" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=151" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=153" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=509" ...
#>   ..$ surface_water.conductivity        : tibble [16 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" ...
#>   .. ..$ Leitfaehigkeit   : chr [1:16] "863" "760" "868" "867" ...
#>   .. ..$ Einheit          : chr [1:16] "µS/cm" "µS/cm" "µS/cm" "µS/cm" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] ">800 - 1000" ">600 - 800" ">800 - 1000" ">800 - 1000" ...
#>   .. ..$ stammdaten_link  : chr [1:16] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=601" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=151" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=153" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=509" ...
#>   ..$ surface_water.ph                  : tibble [16 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" ...
#>   .. ..$ pHWert           : chr [1:16] "7.35" "7.37" "7.40" "7.60" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] ">7.0 - 7.5" ">7.0 - 7.5" ">7.0 - 7.5" ">7.5 - 8.0" ...
#>   .. ..$ stammdaten_link  : chr [1:16] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=601" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=151" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=153" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=509" ...
#>   ..$ surface_water.oxygen_concentration: tibble [16 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" "19.10.2022 06:00" ...
#>   .. ..$ Sauerstoffgehalt : chr [1:16] "0.64" "0.39" "4.92" "2.01" ...
#>   .. ..$ Einheit          : chr [1:16] "mg/l" "mg/l" "mg/l" "mg/l" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] "<= 5" "<= 5" "<= 5" "<= 5" ...
#>   .. ..$ stammdaten_link  : chr [1:16] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=601" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=151" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=153" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=509" ...
#>   ..$ surface_water.oxygen_saturation   : tibble [16 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "18.10.2022 23:00" "18.10.2022 23:00" "18.10.2022 23:00" "18.10.2022 23:00" ...
#>   .. ..$ Parameterwert    : chr [1:16] "45.47" "12.79" "50.51" "21.91" ...
#>   .. ..$ Einheit          : chr [1:16] "%" "%" "%" "%" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] ">25  - 50" "<=25" ">50 - 75" "<=25" ...
#>   .. ..$ stammdaten_link  : chr [1:16] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=601" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=151" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=153" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=owq&sstation=509" ...
#>   ..$ groundwater.level                 : tibble [879 × 11] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer        : int [1:879] 1 2 3 4 9 21 24 25 26 30 ...
#>   .. ..$ Bezirk                   : chr [1:879] "Reinickendorf" "Reinickendorf" "Reinickendorf" "Reinickendorf" ...
#>   .. ..$ Auspraegung              : chr [1:879] "GW-Stand" "GW-Stand" "GW-Stand + GW-Güte" "GW-Stand" ...
#>   .. ..$ Grundwasserleiter        : chr [1:879] "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" ...
#>   .. ..$ Grundwasserspannung      : chr [1:879] "gespannt" "ungespannt" "gespannt" "ungespannt" ...
#>   .. ..$ Datum                    : chr [1:879] "01.09.2022" "01.09.2022" "01.09.2022" "01.09.2022" ...
#>   .. ..$ Grundwasserstand_m_ue_NHN: num [1:879] 33.6 34.8 33.4 32.2 36 ...
#>   .. ..$ Flur_abstand_m_u_GOK     : chr [1:879] "keine Angabe" "2.82" "keine Angabe" "7.65" ...
#>   .. ..$ Ganglinie                : logi [1:879] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation           : chr [1:879] "extrem niedrig" "extrem niedrig" "extrem niedrig" "extrem niedrig" ...
#>   .. ..$ stammdaten_link          : chr [1:879] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=1" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=2" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=3" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=4" ...
#>   ..$ groundwater.quality               : tibble [209 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: int [1:209] 3 145 149 282 344 358 499 580 604 645 ...
#>   .. ..$ Bezirk           : chr [1:209] "Reinickendorf" "Reinickendorf" "Mitte" "Mitte" ...
#>   .. ..$ Auspraegung      : chr [1:209] "GW-Stand + GW-Güte 5" "GW-Stand + GW-Güte 5" "GW-Stand + GW-Güte 5" "GW-Stand + GW-Güte 5" ...
#>   .. ..$ Grundwasserleiter: chr [1:209] "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" ...
#>   .. ..$ Datum            : chr [1:209] "17.11.2021" "18.10.2021" "19.10.2021" "15.11.2021" ...
#>   .. ..$ Parameterwert    : num [1:209] 12.3 11.8 11.8 12.2 13 12.5 12.7 13 15.9 12 ...
#>   .. ..$ Einheit          : chr [1:209] "grd C" "grd C" "grd C" "grd C" ...
#>   .. ..$ Ganglinie        : logi [1:209] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:209] "keine" "keine" "keine" "keine" ...
#>   .. ..$ stammdaten_link  : chr [1:209] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=3" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=145" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=149" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=gws&sstation=282" ...
#>  $ overview_df  :Classes 'data.table' and 'data.frame':  1309 obs. of  27 variables:
#>   ..$ key                      : chr [1:1309] "surface_water.water_level" "surface_water.water_level" "surface_water.water_level" "surface_water.water_level" ...
#>   ..$ Messstellennummer        : chr [1:1309] "5865900" "5827103" "5870400" "5865300" ...
#>   ..$ Messstellenname          : chr [1:1309] "Allee der Kosmonauten" "Allendestraße" "Alsenbrücke" "Am Bahndamm" ...
#>   ..$ Gewaesser                : chr [1:1309] "M.-H.-Grenzgr." "Müggelspree" "Griebnitzkanal" "Wuhle" ...
#>   ..$ Betreiber                : chr [1:1309] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   ..$ Datum                    : chr [1:1309] "19.10.2022 06:30" "19.10.2022 06:30" "19.10.2022 06:30" "19.10.2022 06:30" ...
#>   ..$ Wasserstand              : int [1:1309] 23 52 51 101 73 6 21 73 74 84 ...
#>   ..$ Einheit                  : chr [1:1309] "cm" "cm" "cm" "cm" ...
#>   ..$ Ganglinien               : logi [1:1309] NA NA NA NA NA NA ...
#>   ..$ Klassifikation           : chr [1:1309] "normal" "normal" "niedrig" "normal" ...
#>   ..$ stammdaten_link          : chr [1:1309] "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5865900" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5827103" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5870400" "https://wasserportal.berlin.de/station.php?anzeige=i&stable=ows&sstation=5865300" ...
#>   ..$ Durchfluss               : num [1:1309] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ Ganglinie                : logi [1:1309] NA NA NA NA NA NA ...
#>   ..$ Wassertemperatur         : chr [1:1309] NA NA NA NA ...
#>   ..$ Leitfaehigkeit           : chr [1:1309] NA NA NA NA ...
#>   ..$ pHWert                   : chr [1:1309] NA NA NA NA ...
#>   ..$ Sauerstoffgehalt         : chr [1:1309] NA NA NA NA ...
#>   ..$ Parameterwert            : chr [1:1309] NA NA NA NA ...
#>   ..$ Bezirk                   : chr [1:1309] NA NA NA NA ...
#>   ..$ Auspraegung              : chr [1:1309] NA NA NA NA ...
#>   ..$ Grundwasserleiter        : chr [1:1309] NA NA NA NA ...
#>   ..$ Grundwasserspannung      : chr [1:1309] NA NA NA NA ...
#>   ..$ Grundwasserstand_m_ue_NHN: num [1:1309] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ Flur_abstand_m_u_GOK     : chr [1:1309] NA NA NA NA ...
#>   ..$ water_body               : chr [1:1309] "surface_water" "surface_water" "surface_water" "surface_water" ...
#>   ..$ variable                 : chr [1:1309] "water_level" "water_level" "water_level" "water_level" ...
#>   ..$ station_type             : chr [1:1309] "ws" "ws" "ws" "ws" ...
#>   ..- attr(*, ".internal.selfref")=<externalptr> 
#>  $ crosstable   : tibble [1,010 × 11] (S3: tbl_df/tbl/data.frame)
#>   ..$ Messstellennummer: chr [1:1010] "5865900" "5827103" "5870400" "5865300" ...
#>   ..$ Messstellenname  : chr [1:1010] "Allee der Kosmonauten" "Allendestraße" "Alsenbrücke" "Am Bahndamm" ...
#>   ..$ ws               : chr [1:1010] "x" "x" "x" "x" ...
#>   ..$ df               : chr [1:1010] NA "x" "x" "x" ...
#>   ..$ wt               : chr [1:1010] NA NA NA "x" ...
#>   ..$ lf               : chr [1:1010] NA NA NA NA ...
#>   ..$ ph               : chr [1:1010] NA NA NA NA ...
#>   ..$ og               : chr [1:1010] NA NA NA NA ...
#>   ..$ os               : chr [1:1010] NA NA NA NA ...
#>   ..$ gws              : chr [1:1010] NA NA NA NA ...
#>   ..$ gwq              : chr [1:1010] NA NA NA NA ...

jsonlite::write_json(stations$crosstable, 
                     path = "stations_crosstable.json",
                     pretty = TRUE)
DT::datatable(stations$crosstable, filter = "top", caption = "Data availabilty 
              per monitoring station")

The crosstable data for checking data availabilty of the monitoring stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_crosstable.json

GW level

Master data

Overview data of GW level stations can be requested as shown below:


DT::datatable(stations$overview_list$groundwater.level, filter = "top")

Master data of GW level stations can be requested as shown below:

stations_gwl_master <- wasserportal::get_wasserportal_masters_data(
  master_urls = stations$overview_list$groundwater.level$stammdaten_link
)
#> Importing 879 station metadata from Wasserportal Berlin ... ok. (7.64s)

jsonlite::write_json(stations_gwl_master, 
                     path = "stations_gwl_master.json",
                     pretty = TRUE)

DT::datatable(stations_gwl_master, filter = "top")

The master data of GW level stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_gwl_master.json

Trend Classification

GW level trend classification (provided by SenWeb) is visualized below.

Trend Classification Histogramm

gwl <- stations$overview_list$groundwater.level %>% 
  dplyr::mutate(Datum = as.Date(Datum, format = "%d.%m.%Y"))

text_low_levels <- c("extrem niedrig", "sehr niedrig", "niedrig")
text_high_levels <- c("hoch", "sehr hoch", "extrem hoch")
levels_ordered <- c(text_low_levels, "normal", text_high_levels, "keine")

gwl$Klassifikation <- forcats::fct_relevel(gwl$Klassifikation, levels_ordered)
#> Warning: 1 unknown level in `f`: extrem hoch

gwl_classified_only <- gwl %>% dplyr::filter(Klassifikation != "keine")

percental_share_low_levels <- 100*sum(gwl_classified_only$Klassifikation %in% text_low_levels)/nrow(gwl_classified_only) 

percental_share_high_levels <- 100*sum(gwl_classified_only$Klassifikation %in% text_high_levels)/nrow(gwl_classified_only) 

title_text <- sprintf("GW level classification (n = %d out of %d have 'classification' data)", nrow(gwl_classified_only), nrow(gwl))

g1 <- gwl_classified_only %>% 
  dplyr::count(Klassifikation, Grundwasserspannung) %>% 
  dplyr::mutate(percental_share = 100 * n / nrow(gwl)) %>% 
  ggplot2::ggplot(ggplot2::aes_string(x = "Klassifikation",
                                      y = "percental_share",
                                      fill = "Grundwasserspannung")) +
  ggplot2::geom_bar(stat = "identity") + 
  ggplot2::labs(title = title_text,
                x = "Classification",
                y = "Percental share (%)") +
  ggplot2::theme_bw()

plotly::ggplotly(g1)

88.42 percent of all considered 812 GW level monitoring stations containing classification data (out of 879 provided by SenWeb) indicate below normal (extrem niedrig, sehr niedrig, niedrig) GW levels. However, only 88.42 percent are indicate above normal (hoch, sehr hoch, extrem hoch) GW levels.

Trend Classification Map
level_colors <- data.frame(Klassifikation = levels_ordered, classi_color = c(
  "darkred", "red", "orange", "green", "lightblue", "blue", "darkblue", "grey"
))

gwl_classified_only_with_coords <- gwl_classified_only %>% 
  dplyr::mutate(
    Messstellennummer = as.character(Messstellennummer),
  ) %>% 
  dplyr::left_join(
    stations_gwl_master %>%
      dplyr::select("Nummer", "Rechtswert_UTM_33_N", "Hochwert_UTM_33_N") %>% 
      dplyr::rename(Messstellennummer = "Nummer"),
    by = "Messstellennummer"
  ) %>% 
  dplyr::left_join(
    level_colors, 
    by = "Klassifikation"
  ) %>% 
  sf::st_as_sf(
    coords = c("Rechtswert_UTM_33_N", "Hochwert_UTM_33_N"),
    crs = 25833
  ) %>% 
  sf::st_transform(crs = 4326)

# Create a vector of labels for each row in gwl_classified_only_with_coords
labs <- wasserportal::columns_to_labels(
  data = gwl_classified_only_with_coords, 
  columns = c(
    "Messstellennummer", 
    "Grundwasserspannung", 
    "Klassifikation", 
    "Datum"
  ),
  fmt = "<p>%s: %s</p>",
  sep = ""
)

# Print Map
gwlmap <- gwl_classified_only_with_coords %>% 
  leaflet::leaflet() %>%
  leaflet::addTiles() %>% 
  leaflet::addProviderTiles(leaflet::providers$CartoDB.Positron) %>%
  leaflet::addCircles(
    color = ~classi_color,
    label = lapply(labs, htmltools::HTML)
  ) %>% 
  leaflet::addLegend(
    position = "topright",
    colors = level_colors$classi_color,
    labels = level_colors$Klassifikation,
    title = sprintf(
      "Classification (latest data: %s)",
      max(gwl_classified_only_with_coords$Datum)
    )
  )

htmlwidgets::saveWidget(
  gwlmap, 
  "./map_gwl-trend.html", 
  title = "GW level trend"
)

gwlmap

GW level trend plot is also available on a full html page here: https://kwb-r.github.io/wasserportal/map_gwl-trend.html

Download and Plotting One Station

for total period available.

station_gwl <- stations$overview_list$groundwater.level[1,]
ncols <- 2:ncol(station_gwl)

gw_level <- wasserportal::read_wasserportal_raw_gw(
  station = station_gwl$Messstellennummer, 
  stype = "gwl") %>% 
dplyr::mutate(Label = sprintf("%s (%s)", Parameter, Einheit))
head(gw_level)

g <- gw_level %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", y = "Messwert", col = "Label")) +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()


title_subtitle <- paste0(paste0(names(station_gwl)[1], ": ", 
                             station_gwl[1], 
                             collapse =", "),
       "<br>",
       "<sup>",
       paste0(names(station_gwl)[ncols], ": ",
              station_gwl[ncols], 
              collapse =", "),
       "</sup>")


plotly::ggplotly(g) %>%
  plotly::layout(title = list(text = title_subtitle))

Download and Plotting Multiple Stations

debug <- FALSE
gw_level_multi <- data.table::rbindlist(
  lapply(stations$overview_list$groundwater.level$Messstellennummer, 
                     function(id) {
                       kwb.utils::catAndRun(sprintf("Downloading Messstellennummer == '%s'",
                                                    id), 
                                            expr = {
                       wasserportal::read_wasserportal_raw_gw(
                         station = id, stype = "gwl")
                     }, 
                     dbg = debug)}))


readr::write_csv(gw_level_multi, 
                 file = "groundwater_level.csv")


# Plot 10 GW level
selected_stations <- stations$overview_list$groundwater.level$Messstellennummer[1:10]

g <- gw_level_multi %>% 
dplyr::filter(Messstellennummer %in% selected_stations) %>% 
dplyr::mutate(Messstellennummer = as.character(Messstellennummer)) %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", 
                                    y = "Messwert", 
                                    col = "Messstellennummer")) +
ggplot2::labs(title = "GW level (m above NN)") +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()

plotly::ggplotly(g)

The data of all GW level stations is also available in CSV format here: https://kwb-r.github.io/wasserportal/groundwater_level.csv

GW quality

Overview data of GW level stations can be requested as shown below:

stations_gwq <- wasserportal::get_wasserportal_stations_table(
  type = overview_options$groundwater$quality
  )

DT::datatable(stations_gwq, filter = "top")

Master data of GW quality stations can be requested as shown below:

stations_gwq_master <- wasserportal::get_wasserportal_masters_data(
  master_urls = stations_gwq$stammdaten_link
)
#> Importing 209 station metadata from Wasserportal Berlin ... ok. (1.47s)

jsonlite::write_json(stations_gwq_master, 
                     path = "stations_gwq_master.json",
                     pretty = TRUE)

The master data of GW quality stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_gwq_master.json

GW Quality: Download and Plotting One Station

station_gwq <- stations$overview_list$groundwater.quality[1,]
ncols <- 2:ncol(station_gwq)

gw_quality <- wasserportal::read_wasserportal_raw_gw(
  station = station_gwq$Messstellennummer, 
  stype = "gwq")
head(gw_quality)

unique(gw_quality$Parameter)

g <- gw_quality %>%  
dplyr::filter(Parameter == "Sulfat") %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", y = "Messwert", col = "Parameter")) +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()


title_subtitle <- paste0(paste0(names(station_gwq)[1], ": ", 
                             station_gwq[1], 
                             collapse =", "),
       "<br>",
       "<sup>",
       paste0(names(station_gwq)[ncols], ": ",
              station_gwq[ncols], 
              collapse =", "),
       "</sup>")


plotly::ggplotly(g) %>%
  plotly::layout(title = list(text = title_subtitle))

GW Quality: Download and Plotting Multiple Stations

debug <- FALSE
gw_quality_multi <- data.table::rbindlist(
  lapply(stations$overview_list$groundwater.quality$Messstellennummer, 
                     function(id) {
                       kwb.utils::catAndRun(sprintf("Downloading Messstellennummer == '%s'",
                                                    id), 
                                            expr = {
                       wasserportal::read_wasserportal_raw_gw(
                         station = id, stype = "gwq")
                     }, 
                     dbg = debug)}))


readr::write_csv(gw_quality_multi,
                 "groundwater_quality.csv")


# Plot 10 GW quality 
selected_stations <- stations$overview_list$groundwater.quality$Messstellennummer[1:10]

g <- gw_quality_multi %>% 
dplyr::filter(Messstellennummer %in% selected_stations) %>% 
dplyr::mutate(Messstellennummer = as.character(Messstellennummer)) %>% 
dplyr::filter(Parameter == "Sulfat") %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", 
                                    y = "Messwert", 
                                    col = "Messstellennummer")) +
ggplot2::labs(title = "GW quality (Sulfat)") +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()

plotly::ggplotly(g)

The data of all GW quality stations is also available in CSV format here: https://kwb-r.github.io/wasserportal/groundwater_quality.csv