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]]
## [1] "---/hourly/sun/historical/stundenwerte_SD_03987_18930101_20191231_hist.zip"
## 
## [[2]]
## [1] "---/hourly/sun/historical/stundenwerte_SD_05705_19510101_20191231_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/recent/tageswerte_KL_03987_akt.zip"                       
## [2] "---/daily/kl/historical/tageswerte_KL_03987_18930101_20191231_hist.zip"

There may be a differing number of available files for several stations across all folders. That’s why the default outvec is FALSE (unless per="hr").

selectDWD(id=c(3467,5116), res="",var="",per="") %>% print_short
## [[1]]
## [1] "---/annual/more_precip/historical/jahreswerte_RR_03467_19940101_20191231_hist.zip" 
## [2] "---/annual/more_precip/recent/jahreswerte_RR_03467_akt.zip"                        
## [3] "---/daily/more_precip/historical/tageswerte_RR_03467_19930601_20191231_hist.zip"   
## [4] "---/daily/more_precip/recent/tageswerte_RR_03467_akt.zip"                          
## [5] "---/monthly/more_precip/historical/monatswerte_RR_03467_19930601_20191231_hist.zip"
## [6] "---/monthly/more_precip/recent/monatswerte_RR_03467_akt.zip"                       
## 
## [[2]]
## [1] "---/annual/more_precip/historical/jahreswerte_RR_05116_19930101_20061231_hist.zip" 
## [2] "---/daily/more_precip/historical/tageswerte_RR_05116_19920701_20061231_hist.zip"   
## [3] "---/monthly/more_precip/historical/monatswerte_RR_05116_19920701_20061231_hist.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", outvec=TRUE, quiet=FALSE)
## Warning: rmarkdown::render_site -> generator$render -> in_dir -> selectDWD -
## > findID: ID determined from name 'Berlin' has 43 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,
## 4537, 4751, 4894, 5138, 5432, 6193, 15186).
## Warning: rmarkdown::render_site -> generator$render -> in_dir -> selectDWD:
## according to file index 'fileIndex', there is no file in '/monthly/kl/
## historical' with ID 401, 404, 406, 409, 412, 413, 414, 418, 419, 421, 426, 394,
## 436, 437, 4894, 6193, 4537, 4751, 15186, 5432.
str(  print_short(bd[bd!=dwdbase])  )
##  chr [1:23] "---/monthly/kl/historical/monatswerte_KL_00395_19480701_19531231_hist.zip" ...