5 Station selection

print_short in this chapter is just a helper function to replace dwdbase with --- for shorter output.

5.1 by location

Weather stations can be selected geographically with the interactive map. All stations within a certain radius around a given lat-long position can be obtained with nearbyStations.

5.2 by ID

The DWD station IDs can be obtained from station names with findID:

findID("Potsdam")
## Potsdam 
##    3987
findID("Koeln", exactmatch=FALSE)
##               Koeln-Bonn Koeln-Botanischer Garten           Koeln-Porz-Eil 
##                     2667                     2665                     2666 
##          Koeln-Stammheim 
##                     2968

5.3 by name

File selection by station name/id and folder can happen directly with selectDWD. It is designed to be very flexible:

# inputs can be vectorized, and period can be abbreviated:
selectDWD(c("Potsdam","Wuerzburg"), res="hourly", var="sun", per="hist") %>% print_short
## [1] "---/hourly/sun/historical/stundenwerte_SD_03987_18930101_20221231_hist.zip"
## [2] "---/hourly/sun/historical/stundenwerte_SD_05705_19510101_20221231_hist.zip"

If res/var/per are left NA, an interactive selection is opened with the available folder options for the given station.

The time period can be doubled to get both filenames:

selectDWD("Potsdam", res="daily", var="kl", per="rh") %>% print_short
## [1] "---/daily/kl/historical/tageswerte_KL_03987_18930101_20221231_hist.zip"
## [2] "---/daily/kl/recent/tageswerte_KL_03987_akt.zip"

There may be a differing number of available files for several stations across all folders.

selectDWD(id=c(3467,5116), res="",var="",per="") %>% print_short
##  [1] "---/annual/climate_indices/precip/historical/jahreswerte_RRINDEX_03467_19940101_20221231_hist.zip" 
##  [2] "---/annual/climate_indices/precip/historical/jahreswerte_RRINDEX_05116_19930101_20061231_hist.zip" 
##  [3] "---/annual/climate_indices/precip/recent/jahreswerte_RRINDEX_03467_akt.zip"                        
##  [4] "---/annual/more_precip/historical/jahreswerte_RR_03467_19930601_20221231_hist.zip"                 
##  [5] "---/annual/more_precip/historical/jahreswerte_RR_05116_19920701_20061231_hist.zip"                 
##  [6] "---/annual/more_precip/recent/jahreswerte_RR_03467_akt.zip"                                        
##  [7] "---/daily/more_precip/historical/tageswerte_RR_03467_19930601_20221231_hist.zip"                   
##  [8] "---/daily/more_precip/historical/tageswerte_RR_05116_19920701_20061231_hist.zip"                   
##  [9] "---/daily/more_precip/recent/tageswerte_RR_03467_akt.zip"                                          
## [10] "---/daily/more_weather_phenomena/historical/wetter_tageswerte_RR_03467_19930601_20111031_hist.zip" 
## [11] "---/daily/more_weather_phenomena/historical/wetter_tageswerte_RR_05116_19920701_20061231_hist.zip" 
## [12] "---/monthly/climate_indices/precip/historical/monatswerte_RRINDEX_03467_19930601_20221231_hist.zip"
## [13] "---/monthly/climate_indices/precip/historical/monatswerte_RRINDEX_05116_19920701_20061231_hist.zip"
## [14] "---/monthly/climate_indices/precip/recent/monatswerte_RRINDEX_03467_akt.zip"                       
## [15] "---/monthly/more_precip/historical/monatswerte_RR_03467_19930601_20221231_hist.zip"                
## [16] "---/monthly/more_precip/historical/monatswerte_RR_05116_19920701_20061231_hist.zip"                
## [17] "---/monthly/more_precip/recent/monatswerte_RR_03467_akt.zip"

Since version 1.3.26 (2020-07-20), SelectDWD collects warnings from the loop into a single message:

# out of 43 stations with a partial match for the name "Berlin", only 20 have data in the folowing folder
bd <- selectDWD("Berlin", exactmatch=FALSE, res="monthly", var="kl", per="h", quiet=FALSE)
## Warning: rmarkdown::render_site -> generator$render -> in_dir -> knitr::knit ->
## process_file -> process_group -> process_group.block -> call_block ->
## block_exec -> selectDWD -> force -> findID: ID determined from name 'Berlin'
## has 44 elements (394, 395, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408,
## 409, 410, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422, 424, 425, 426, 427,
## 429, 430, 432, 433, 434, 435, 436, 437, 3147, 4537, 4751, 4894, 5138, 5432,
## 6193, 15186).
str(  print_short(bd[bd!=dwdbase])  )
##  chr [1:24] "---/monthly/kl/historical/monatswerte_KL_00395_19480701_19531231_hist.zip" ...