Title: | R Package with Functions Used in Project IMPETUS |
---|---|
Description: | R Package with Functions used in Project IMPETUS. |
Authors: | Michael Rustler [aut, cre] , IMPETUS [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
Maintainer: | Michael Rustler <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-10-30 03:32:14 UTC |
Source: | https://github.com/KWB-R/kwb.impetus |
Label for Decade Year Range
decade_label(decade)
decade_label(decade)
decade |
start of decade as integer, e.g. 1990L |
character string, e.g. "1990 - 1999"
ggplot2 ribbon between q05 and q95
decade_ribbons(alpha = 0.1)
decade_ribbons(alpha = 0.1)
alpha |
passed to |
Tibble with Decade Names and Values
decades_tibble( decade_labels, colors = c("darkblue", "blue", "darkgreen", "lightgreen", "orange", "red") )
decades_tibble( decade_labels, colors = c("darkblue", "blue", "darkgreen", "lightgreen", "orange", "red") )
decade_labels |
decade labels |
colors |
colour values |
tibble with columns names
and values
Download GFZ Model Layers
download_gfz_model(target_dir = tempdir())
download_gfz_model(target_dir = tempdir())
target_dir |
target directory to extract files (default: tempdir()) |
extracts GFZ model layers in target directory
A dataset containing the precipitation and potential diamonds.
dwd_berlin_monthly
dwd_berlin_monthly
A data frame with 3852 rows and 12 variables:
self-defined name for parameter
original DWD parameter name (required for requests)
name of raw data file
year
month
spatial mean value for month
spatial standard deviation value for month
spatial minimum value for month
spatial maximum value for month
number of 1x1km2 grids used for spatial statistics calculation
parameter name
full url to raw data file
## Not run: ############################################################################ #### R code used for creation of "dwd_berlin_monthly.rds" ############################################################################ remotes::install_github("kwb-r/kwb.dwd") library(kwb.impetus) shape_obj <- kwb.dwd:::get_shape_of_german_region(name = "berlin") shape_file <- "berlin.shp" shape_obj %>% sf::st_as_sf() %>% sf::write_sf(shape_file) ### Plot to check if Berlin boundaries are plotted correctly. ### Set target CRS crs_target <- 4326 shape_pt <- sf::st_read(shape_file) %>% sf::st_transform(crs = crs_target) basemap <- shape_pt %>% leaflet::leaflet() %>% leaflet::addTiles() %>% leaflet::addProviderTiles(leaflet::providers$CartoDB.Positron) %>% leaflet::addPolygons(color = "red", fill = FALSE) basemap yearmonth_start <- "188101" yearmonth_end <- "202208" kwb.dwd:::list_monthly_grids_germany_asc_gz("x") dwd_monthly_vars <- c(#"air temperature (mean)" = "air_temperature_mean"#, "drought index" = "drought_index", "evaporation, potential" = "evapo_p", "evaporation, real" = "evapo_r", "precipitation" = "precipitation", "soil moisture" = "soil_moist", "soil temperature (5 cm)" = "soil_temperature_5cm" ) system.time( dwd_berlin_monthly_list <- stats::setNames(lapply(dwd_monthly_vars, function(dwd_var) { kwb.dwd::read_monthly_data_over_shape( file = shape_file, variable = dwd_var, from = yearmonth_start, to = yearmonth_end, quiet = TRUE ) }), nm = dwd_monthly_vars)) dwd_berlin_monthly <- dplyr::bind_rows(dwd_berlin_monthly_list, .id = "parameter") dwd_berlin_monthly <- tibble::tibble(parameter_name = names(dwd_monthly_vars), parameter = as.character(dwd_monthly_vars)) %>% dplyr::left_join(dwd_berlin_monthly) usethis::use_data(dwd_berlin_monthly, overwrite = TRUE) ## End(Not run) # Dataset dwd_berlin_monthly # Covered time period for each parameter dwd_berlin_monthly %>% dplyr::group_by(.data$parameter_name, .data$parameter) %>% dplyr::summarise(date_min = min(.data$date), date_max = max(.data$date))
## Not run: ############################################################################ #### R code used for creation of "dwd_berlin_monthly.rds" ############################################################################ remotes::install_github("kwb-r/kwb.dwd") library(kwb.impetus) shape_obj <- kwb.dwd:::get_shape_of_german_region(name = "berlin") shape_file <- "berlin.shp" shape_obj %>% sf::st_as_sf() %>% sf::write_sf(shape_file) ### Plot to check if Berlin boundaries are plotted correctly. ### Set target CRS crs_target <- 4326 shape_pt <- sf::st_read(shape_file) %>% sf::st_transform(crs = crs_target) basemap <- shape_pt %>% leaflet::leaflet() %>% leaflet::addTiles() %>% leaflet::addProviderTiles(leaflet::providers$CartoDB.Positron) %>% leaflet::addPolygons(color = "red", fill = FALSE) basemap yearmonth_start <- "188101" yearmonth_end <- "202208" kwb.dwd:::list_monthly_grids_germany_asc_gz("x") dwd_monthly_vars <- c(#"air temperature (mean)" = "air_temperature_mean"#, "drought index" = "drought_index", "evaporation, potential" = "evapo_p", "evaporation, real" = "evapo_r", "precipitation" = "precipitation", "soil moisture" = "soil_moist", "soil temperature (5 cm)" = "soil_temperature_5cm" ) system.time( dwd_berlin_monthly_list <- stats::setNames(lapply(dwd_monthly_vars, function(dwd_var) { kwb.dwd::read_monthly_data_over_shape( file = shape_file, variable = dwd_var, from = yearmonth_start, to = yearmonth_end, quiet = TRUE ) }), nm = dwd_monthly_vars)) dwd_berlin_monthly <- dplyr::bind_rows(dwd_berlin_monthly_list, .id = "parameter") dwd_berlin_monthly <- tibble::tibble(parameter_name = names(dwd_monthly_vars), parameter = as.character(dwd_monthly_vars)) %>% dplyr::left_join(dwd_berlin_monthly) usethis::use_data(dwd_berlin_monthly, overwrite = TRUE) ## End(Not run) # Dataset dwd_berlin_monthly # Covered time period for each parameter dwd_berlin_monthly %>% dplyr::group_by(.data$parameter_name, .data$parameter) %>% dplyr::summarise(date_min = min(.data$date), date_max = max(.data$date))
floors to previous decade.
floor_decade(value)
floor_decade(value)
value |
year |
decade
floor_decade(2000:2020)
floor_decade(2000:2020)
Continuous x scale for months
ggplot2_scale_x_continuous_12()
ggplot2_scale_x_continuous_12()
Group by Dekade_Label
group_by_decade_label(data)
group_by_decade_label(data)
data |
data frame |
Group by Decade, Decade_Label, Month, Label
group_by_decade_month_label(data)
group_by_decade_month_label(data)
data |
data frame |
Group by Messstellennummer, Decade, Decade_Label, Month, Label
group_by_site_decade_month_label(data)
group_by_site_decade_month_label(data)
data |
data frame |
Group by Messstellennummer, Year, Month, Label
group_by_site_year_month_label(data)
group_by_site_year_month_label(data)
data |
data frame |
Group by Year, Month
group_by_year_month(data)
group_by_year_month(data)
data |
data frame |
Unnamed Quantile Value
numeric_quantile(x, prob)
numeric_quantile(x, prob)
x |
vector of numeric |
prob |
probability passed to |
Plot GFZ Model Raster Layer
plot_gfz_layer(layer)
plot_gfz_layer(layer)
layer |
a layer as retrieved by |
plot raster layer
Extracted parts of table on page 16 from Niedrigwasserbericht 2018-2020 by
SenUVK Berlin. Contains only flows from inflows
to Berlin (i.e. no
data from Sophienwerder
and Muehlendammschleuse
ware imported)
q_surface_water
q_surface_water
A data frame with 6 rows and 10 variables:
name of surface water
name of monitoring station
MQ for period 1991-2017 (m3/s))
MQ for period 1991-2017 (m3/s)
MQ for period 1991-2017 (m3/s))
NNQ value (m3/s)
Date of nnq.value (NA if "often" !)
MQ of year 2018 (m3/s)
MQ of year 2019 (m3/s)
MQ of year 2020 (m3/s)
kwb.impetus::q_surface_water
kwb.impetus::q_surface_water
Reads a single GFZ Model Layer
read_gfz_layer(path, as_raster)
read_gfz_layer(path, as_raster)
path |
path to GFZ Model Layer |
as_raster |
convert to raster (default: TRUE) |
imported layer file
Reads multiple GFZ Model Layers
read_gfz_layers( dir_model_data, type = "elevation", as_raster = TRUE, dbg = TRUE )
read_gfz_layers( dir_model_data, type = "elevation", as_raster = TRUE, dbg = TRUE )
dir_model_data |
path to GFZ Model Layer Data as retrieved by |
as_raster |
convert to raster (default: TRUE) |
dbg |
print debug messaages (default: TRUE) |
imported layer files
rounds to next decade if end year is >=5 or floors to previous decade if end year <5.
round_to_decade(values)
round_to_decade(values)
values |
year |
decade
round_to_decade(2000:2020)
round_to_decade(2000:2020)
ggplot2: scale color decades
scale_color_decades(decades, ...)
scale_color_decades(decades, ...)
decades |
decades |
... |
additional arguments passed to xxx |
re-scales ggplot2
ggplot2: scale fill decades
scale_fill_decades(decades, ...)
scale_fill_decades(decades, ...)
decades |
decades |
... |
additional arguments passed to xxx |
re-scales ggplot2