Define Helper Functions
write_pretty_json <- function(x, path) {
jsonlite::write_json(x, path = path, pretty = TRUE)
}
top_filter_datatable <- function(x, caption = NULL) {
DT::datatable(x, filter = "top", caption = caption)
}
create_title_text <- function(x, ncols) {
paste0(
paste0(names(x)[1L], ": ", x[1L], collapse = ", "),
"<br>",
"<sup>",
paste0(names(x)[ncols], ": ", x[ncols], collapse =", "),
"</sup>"
)
}
also_available <- function(what, format, filename) {
cat(paste0(
what,
" is also available ",
format,
" here: ",
"[https://kwb-r.github.io/wasserportal/", filename, "]",
"(../", filename, ")"
))
}
ggplot2_date_value <- function(data, col) {
ggplot2::ggplot(data, mapping = ggplot2::aes(
x = Datum,
y = Messwert,
col = col
))
}
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 "ows"
#> ..$ flow : chr "odf"
#> ..$ temperature : chr "owt"
#> ..$ conductivity : chr "olf"
#> ..$ ph : chr "oph"
#> ..$ oxygen_concentration: chr "oog"
#> ..$ oxygen_saturation : chr "oos"
#> $ groundwater :List of 2
#> ..$ level : chr "gws"
#> ..$ quality: chr "gwq"
system.time(stations <- wasserportal::get_stations())
#> Importing 9 station overviews from Wasserportal Berlin ... ok. (9.40 secs)
#> user system elapsed
#> 0.062 0.012 9.702
str(stations)
#> List of 3
#> $ overview_list:List of 9
#> ..$ surface_water.water_level : tibble [108 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: int [1:108] 5865900 5827103 5870400 5865300 5819900 5864801 5861101 5800107 5800317 5867003 ...
#> .. ..$ Messstellenname : chr [1:108] "Allee der Kosmonauten" "Allendestraße" "Alsenbrücke" "Am Bahndamm" ...
#> .. ..$ Gewaesser : chr [1:108] "M.-H.-Grenzgr." "Müggelspree" "Griebnitzkanal" "Wuhle" ...
#> .. ..$ Betreiber : chr [1:108] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:108] "02.12.2023 11:45" "02.12.2023 11:45" "02.12.2023 11:45" "16.02.2023 13:30" ...
#> .. ..$ Wasserstand : num [1:108] 5 51 53 34 90 4 30 70 77 53 ...
#> .. ..$ Einheit : chr [1:108] "cm" "cm" "cm" "cm" ...
#> .. ..$ Ganglinien : chr [1:108] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5865900" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5827103" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5870400" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5865300" ...
#> .. ..$ Klassifikation : chr [1:108] "niedrig" "niedrig" "niedrig" "nicht aktuell" ...
#> .. ..$ stammdaten_link : chr [1:108] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5865900" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5827103" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5870400" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5865300" ...
#> ..$ surface_water.flow : tibble [39 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: int [1:39] 5827103 5870400 5865300 5864801 5867401 5867900 5827101 5870100 5826701 5862811 ...
#> .. ..$ Messstellenname : chr [1:39] "Allendestraße" "Alsenbrücke" "Am Bahndamm" "Am Kienberg" ...
#> .. ..$ Gewaesser : chr [1:39] "Müggelspree" "Griebnitzkanal" "Wuhle" "Hellersdorfer Graben" ...
#> .. ..$ Betreiber : chr [1:39] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:39] "01.05.2022 00:00" "" "16.02.2023 13:30" "02.12.2023 11:15" ...
#> .. ..$ Durchfluss : num [1:39] 4.08 NA 0.165 0.001 1.33 0.266 5.44 2.92 7.95 14.6 ...
#> .. ..$ Einheit : chr [1:39] "m³/s" "m³/s" "m³/s" "m³/s" ...
#> .. ..$ Ganglinie : chr [1:39] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=odf&station=5827103" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=odf&station=5870400" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=odf&station=5865300" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=odf&station=5864801" ...
#> .. ..$ Klassifikation : chr [1:39] "nicht aktuell" "nicht aktuell" "nicht aktuell" "keine" ...
#> .. ..$ stammdaten_link : chr [1:39] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=odf&station=5827103" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=odf&station=5870400" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=odf&station=5865300" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=odf&station=5864801" ...
#> ..$ surface_water.temperature : tibble [65 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: chr [1:65] "601" "151" "153" "509" ...
#> .. ..$ Messstellenname : chr [1:65] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#> .. ..$ Gewaesser : chr [1:65] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#> .. ..$ Betreiber : chr [1:65] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:65] "27.10.2023 09:30" "27.10.2023 10:15" "27.10.2023 10:00" "27.10.2023 09:15" ...
#> .. ..$ Wassertemperatur : chr [1:65] "12.20" "12.04" "12.05" "11.97" ...
#> .. ..$ Einheit : chr [1:65] "°C" "°C" "°C" "°C" ...
#> .. ..$ Ganglinie : chr [1:65] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=owt&station=601" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=owt&station=151" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=owt&station=153" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=owt&station=509" ...
#> .. ..$ Klassifikation : chr [1:65] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#> .. ..$ stammdaten_link : chr [1:65] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=owt&station=601" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=owt&station=151" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=owt&station=153" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=owt&station=509" ...
#> ..$ surface_water.conductivity : tibble [17 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: chr [1:17] "601" "151" "153" "509" ...
#> .. ..$ Messstellenname : chr [1:17] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#> .. ..$ Gewaesser : chr [1:17] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#> .. ..$ Betreiber : chr [1:17] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:17] "27.10.2023 09:30" "27.10.2023 10:15" "27.10.2023 10:00" "27.10.2023 09:15" ...
#> .. ..$ Leitfaehigkeit : chr [1:17] "806" "798" "804" "810" ...
#> .. ..$ Einheit : chr [1:17] "µS/cm" "µS/cm" "µS/cm" "µS/cm" ...
#> .. ..$ Ganglinie : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=olf&station=601" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=olf&station=151" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=olf&station=153" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=olf&station=509" ...
#> .. ..$ Klassifikation : chr [1:17] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#> .. ..$ stammdaten_link : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=olf&station=601" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=olf&station=151" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=olf&station=153" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=olf&station=509" ...
#> ..$ surface_water.ph : tibble [17 × 9] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: chr [1:17] "601" "151" "153" "509" ...
#> .. ..$ Messstellenname : chr [1:17] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#> .. ..$ Gewaesser : chr [1:17] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#> .. ..$ Betreiber : chr [1:17] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:17] "27.10.2023 09:30" "27.10.2023 10:15" "27.10.2023 10:00" "27.10.2023 09:15" ...
#> .. ..$ pHWert : chr [1:17] "7.73" "7.64" "7.40" "7.51" ...
#> .. ..$ Ganglinie : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oph&station=601" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oph&station=151" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oph&station=153" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oph&station=509" ...
#> .. ..$ Klassifikation : chr [1:17] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#> .. ..$ stammdaten_link : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oph&station=601" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oph&station=151" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oph&station=153" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oph&station=509" ...
#> ..$ surface_water.oxygen_concentration: tibble [17 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: chr [1:17] "601" "151" "153" "509" ...
#> .. ..$ Messstellenname : chr [1:17] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#> .. ..$ Gewaesser : chr [1:17] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#> .. ..$ Betreiber : chr [1:17] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:17] "27.10.2023 09:30" "27.10.2023 10:15" "27.10.2023 10:00" "27.10.2023 09:15" ...
#> .. ..$ Sauerstoffgehalt : chr [1:17] "7.67" "7.53" "7.33" "4.00" ...
#> .. ..$ Einheit : chr [1:17] "mg/l" "mg/l" "mg/l" "mg/l" ...
#> .. ..$ Ganglinie : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oog&station=601" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oog&station=151" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oog&station=153" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oog&station=509" ...
#> .. ..$ Klassifikation : chr [1:17] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#> .. ..$ stammdaten_link : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oog&station=601" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oog&station=151" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oog&station=153" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oog&station=509" ...
#> ..$ surface_water.oxygen_saturation : tibble [17 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: chr [1:17] "601" "151" "153" "509" ...
#> .. ..$ Messstellenname : chr [1:17] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#> .. ..$ Gewaesser : chr [1:17] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#> .. ..$ Betreiber : chr [1:17] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> .. ..$ Datum : chr [1:17] "27.10.2023 09:30" "27.10.2023 10:15" "27.10.2023 10:00" "27.10.2023 09:15" ...
#> .. ..$ Parameterwert : chr [1:17] "71.71" "70.15" "68.30" "37.20" ...
#> .. ..$ Einheit : chr [1:17] "%" "%" "%" "%" ...
#> .. ..$ Ganglinie : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oos&station=601" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oos&station=151" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oos&station=153" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=oos&station=509" ...
#> .. ..$ Klassifikation : chr [1:17] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#> .. ..$ stammdaten_link : chr [1:17] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oos&station=601" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oos&station=151" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oos&station=153" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=oos&station=509" ...
#> ..$ groundwater.level : tibble [893 × 11] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer : int [1:893] 1 2 3 4 9 21 24 25 26 30 ...
#> .. ..$ Bezirk : chr [1:893] "Reinickendorf" "Reinickendorf" "Reinickendorf" "Reinickendorf" ...
#> .. ..$ Auspraegung : chr [1:893] "GW-Stand" "GW-Stand" "GW-Stand + GW-Güte" "GW-Stand" ...
#> .. ..$ Grundwasserleiter : chr [1:893] "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" ...
#> .. ..$ Grundwasserspannung : chr [1:893] "gespannt" "ungespannt" "gespannt" "ungespannt" ...
#> .. ..$ Datum : chr [1:893] "10.11.2023" "10.11.2023" "10.11.2023" "10.11.2023" ...
#> .. ..$ Grundwasserstand_m_ue_NHN: num [1:893] 33.6 35 33.6 32.4 37 ...
#> .. ..$ Flur_abstand_m_u_GOK : chr [1:893] "keine Angabe" "2.61" "keine Angabe" "7.45" ...
#> .. ..$ Ganglinie : chr [1:893] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gws&station=1" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gws&station=2" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gws&station=3" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gws&station=4" ...
#> .. ..$ Klassifikation : chr [1:893] "extrem niedrig" "sehr niedrig" "niedrig" "sehr niedrig" ...
#> .. ..$ stammdaten_link : chr [1:893] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gws&station=1" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gws&station=2" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gws&station=3" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gws&station=4" ...
#> ..$ groundwater.quality : tibble [213 × 10] (S3: tbl_df/tbl/data.frame)
#> .. ..$ Messstellennummer: int [1:213] 3 145 149 282 344 358 499 580 604 645 ...
#> .. ..$ Bezirk : chr [1:213] "Reinickendorf" "Reinickendorf" "Mitte" "Mitte" ...
#> .. ..$ Auspraegung : chr [1:213] "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:213] "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" ...
#> .. ..$ Datum : chr [1:213] "14.11.2022" "27.09.2022" "06.12.2022" "10.11.2022" ...
#> .. ..$ Parameterwert : num [1:213] 12.2 10.9 13.1 12.2 13 12.3 13 13.1 15.6 11.8 ...
#> .. ..$ Einheit : chr [1:213] "°C" "°C" "°C" "°C" ...
#> .. ..$ Ganglinie : chr [1:213] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gwq&station=3&nstoffid=10" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gwq&station=145&nstoffid=10" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gwq&station=149&nstoffid=10" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=gwq&station=282&nstoffid=10" ...
#> .. ..$ Klassifikation : chr [1:213] "keine" "keine" "keine" "keine" ...
#> .. ..$ stammdaten_link : chr [1:213] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gwq&station=3" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gwq&station=145" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gwq&station=149" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=gwq&station=282" ...
#> $ overview_df :Classes 'data.table' and 'data.frame': 1386 obs. of 27 variables:
#> ..$ key : chr [1:1386] "surface_water.water_level" "surface_water.water_level" "surface_water.water_level" "surface_water.water_level" ...
#> ..$ Messstellennummer : chr [1:1386] "5865900" "5827103" "5870400" "5865300" ...
#> ..$ Messstellenname : chr [1:1386] "Allee der Kosmonauten" "Allendestraße" "Alsenbrücke" "Am Bahndamm" ...
#> ..$ Gewaesser : chr [1:1386] "M.-H.-Grenzgr." "Müggelspree" "Griebnitzkanal" "Wuhle" ...
#> ..$ Betreiber : chr [1:1386] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#> ..$ Datum : chr [1:1386] "02.12.2023 11:45" "02.12.2023 11:45" "02.12.2023 11:45" "16.02.2023 13:30" ...
#> ..$ Wasserstand : num [1:1386] 5 51 53 34 90 4 30 70 77 53 ...
#> ..$ Einheit : chr [1:1386] "cm" "cm" "cm" "cm" ...
#> ..$ Ganglinien : chr [1:1386] "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5865900" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5827103" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5870400" "https://wasserportal.berlin.de/station.php?anzeige=g&thema=ows&station=5865300" ...
#> ..$ Klassifikation : chr [1:1386] "niedrig" "niedrig" "niedrig" "nicht aktuell" ...
#> ..$ stammdaten_link : chr [1:1386] "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5865900" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5827103" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5870400" "https://wasserportal.berlin.de/station.php?anzeige=i&thema=ows&station=5865300" ...
#> ..$ Durchfluss : num [1:1386] NA NA NA NA NA NA NA NA NA NA ...
#> ..$ Ganglinie : chr [1:1386] NA NA NA NA ...
#> ..$ Wassertemperatur : chr [1:1386] NA NA NA NA ...
#> ..$ Leitfaehigkeit : chr [1:1386] NA NA NA NA ...
#> ..$ pHWert : chr [1:1386] NA NA NA NA ...
#> ..$ Sauerstoffgehalt : chr [1:1386] NA NA NA NA ...
#> ..$ Parameterwert : chr [1:1386] NA NA NA NA ...
#> ..$ Bezirk : chr [1:1386] NA NA NA NA ...
#> ..$ Auspraegung : chr [1:1386] NA NA NA NA ...
#> ..$ Grundwasserleiter : chr [1:1386] NA NA NA NA ...
#> ..$ Grundwasserspannung : chr [1:1386] NA NA NA NA ...
#> ..$ Grundwasserstand_m_ue_NHN: num [1:1386] NA NA NA NA NA NA NA NA NA NA ...
#> ..$ Flur_abstand_m_u_GOK : chr [1:1386] NA NA NA NA ...
#> ..$ water_body : chr [1:1386] "surface_water" "surface_water" "surface_water" "surface_water" ...
#> ..$ variable : chr [1:1386] "water_level" "water_level" "water_level" "water_level" ...
#> ..$ station_type : chr [1:1386] "ows" "ows" "ows" "ows" ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> $ crosstable : tibble [1,054 × 11] (S3: tbl_df/tbl/data.frame)
#> ..$ Messstellennummer: chr [1:1054] "5865900" "5827103" "5870400" "5865300" ...
#> ..$ Messstellenname : chr [1:1054] "Allee der Kosmonauten" "Allendestraße" "Alsenbrücke" "Am Bahndamm" ...
#> ..$ ows : chr [1:1054] "x" "x" "x" "x" ...
#> ..$ odf : chr [1:1054] NA "x" "x" "x" ...
#> ..$ owt : chr [1:1054] NA NA NA "x" ...
#> ..$ olf : chr [1:1054] NA NA NA NA ...
#> ..$ oph : chr [1:1054] NA NA NA NA ...
#> ..$ oog : chr [1:1054] NA NA NA NA ...
#> ..$ oos : chr [1:1054] NA NA NA NA ...
#> ..$ gws : chr [1:1054] NA NA NA NA ...
#> ..$ gwq : chr [1:1054] NA NA NA NA ...
write_pretty_json(stations$crosstable, "stations_crosstable.json")
top_filter_datatable(
stations$crosstable,
"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:
top_filter_datatable(stations$overview_list$groundwater.level)
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 893 station metadata from Wasserportal Berlin ... ok. (8.95 mins)
write_pretty_json(stations_gwl_master, "stations_gwl_master.json")
top_filter_datatable(stations_gwl_master)
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)
gwl_classified_only <- gwl %>%
dplyr::filter(Klassifikation != "keine")
percental_share_low_levels <- kwb.utils::percentage(
sum(gwl_classified_only$Klassifikation %in% text_low_levels),
basis = nrow(gwl_classified_only)
)
percental_share_high_levels <- kwb.utils::percentage(
sum(gwl_classified_only$Klassifikation %in% text_high_levels),
basis = 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 = kwb.utils::percentage(n, nrow(gwl))) %>%
ggplot2::ggplot(ggplot2::aes(
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)
61.17 percent of all considered 801 GW level monitoring stations
containing classification
data (out of 893 provided by
SenWeb) indicate below normal
(extrem niedrig, sehr
niedrig, niedrig) GW levels. However, only 61.17 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"
)
)
rechtswert <- "Rechtswert_UTM_33_N"
hochwert <- "Hochwert_UTM_33_N"
gwl_classified_only_with_coords <- gwl_classified_only %>%
dplyr::mutate(
Messstellennummer = as.character(Messstellennummer),
) %>%
dplyr::left_join(
stations_gwl_master %>%
dplyr::select(dplyr::all_of(c("Nummer", rechtswert, hochwert))) %>%
dplyr::rename(Messstellennummer = "Nummer"),
by = "Messstellennummer"
) %>%
dplyr::left_join(
level_colors,
by = "Klassifikation"
) %>%
sf::st_as_sf(
coords = c(rechtswert, hochwert),
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[1L, ]
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_date_value(col = "Label") +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()
title_subtitle <- create_title_text(x = station_gwl, ncols = ncols)
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),
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_date_value(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
)
top_filter_datatable(stations_gwq)
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 213 station metadata from Wasserportal Berlin ... ok. (2.19 mins)
write_pretty_json(stations_gwq_master, "stations_gwq_master.json")
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[1L, ]
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_date_value(col = "Parameter") +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()
title_subtitle <- create_title_text(x = station_gwq, ncols = ncols)
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),
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_date_value(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