Skip to contents

A dataset containing the precipitation and potential diamonds.

Usage

dwd_berlin_monthly

Format

A data frame with 3852 rows and 12 variables:

parameter_name

self-defined name for parameter

parameter

original DWD parameter name (required for requests)

file

name of raw data file

year

year

month

month

mean

spatial mean value for month

sd

spatial standard deviation value for month

min

spatial minimum value for month

max

spatial maximum value for month

n_values

number of 1x1km2 grids used for spatial statistics calculation

parameter

parameter name

url

full url to raw data file

Examples

if (FALSE) { # \dontrun{
############################################################################
#### 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)

} # } 



# Dataset

dwd_berlin_monthly
#> # A tibble: 3,852 × 11
#>    parameter_name parameter     file   date        year month  mean     sd   min
#>    <chr>          <chr>         <chr>  <date>     <int> <int> <dbl>  <dbl> <dbl>
#>  1 drought index  drought_index grids… 1970-01-01  1970     1  7.32 0.955      5
#>  2 drought index  drought_index grids… 1971-01-01  1971     1  2.00 0.115      1
#>  3 drought index  drought_index grids… 1972-01-01  1972     1  1.99 0.0938     1
#>  4 drought index  drought_index grids… 1973-01-01  1973     1  2.48 0.500      2
#>  5 drought index  drought_index grids… 1974-01-01  1974     1  2.02 0.151      2
#>  6 drought index  drought_index grids… 1975-01-01  1975     1  2.87 0.332      2
#>  7 drought index  drought_index grids… 1976-01-01  1976     1  9.05 0.500      8
#>  8 drought index  drought_index grids… 1977-01-01  1977     1  2.23 0.421      2
#>  9 drought index  drought_index grids… 1978-01-01  1978     1  1.76 0.428      1
#> 10 drought index  drought_index grids… 1979-01-01  1979     1  5.10 0.528      4
#> # ℹ 3,842 more rows
#> # ℹ 2 more variables: max <dbl>, n_values <dbl>


# 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))
#> `summarise()` has grouped output by 'parameter_name'. You can override using
#> the `.groups` argument.
#> # A tibble: 6 × 4
#> # Groups:   parameter_name [6]
#>   parameter_name          parameter            date_min   date_max  
#>   <chr>                   <chr>                <date>     <date>    
#> 1 drought index           drought_index        1970-01-01 2022-08-01
#> 2 evaporation, potential  evapo_p              1991-01-01 2022-08-01
#> 3 evaporation, real       evapo_r              1991-01-01 2022-08-01
#> 4 precipitation           precipitation        1881-01-01 2022-08-01
#> 5 soil moisture           soil_moist           1991-01-01 2022-08-01
#> 6 soil temperature (5 cm) soil_temperature_5cm 1991-01-01 2022-08-01