selectDWD {rdwd} | R Documentation |
Select data from the DWD CDC FTP Server
Description
Select data files for downloading with dataDWD()
.
The available res/var/per
folders with datasets are listed
online.
Set res="", var="", per=""
to avoid the default interactive selection.
The arguments name/id
and res/var/per
can be vectors.
Usage
selectDWD(
name = "",
res = NA,
var = NA,
per = NA,
expand = TRUE,
id = findID(name, exactmatch = exactmatch, mindex = mindex, quiet = quiet, failempty =
failempty),
exactmatch = TRUE,
mindex = metaIndex,
failempty = TRUE,
findex = fileIndex,
current = FALSE,
base = dwdbase,
meta = FALSE,
quiet = rdwdquiet(),
...
)
Arguments
name |
Char: station name(s) passed to |
res |
Char: temporal resolution at |
var |
Char: weather variable of interest, e.g.
|
per |
Char: desired time period, e.g.
"recent" (up to date records from the last 1.5 years) or
"historical" (long time series).
Can be abbreviated. To get both datasets, use |
expand |
Logical: get all possible |
id |
Char/Number: station ID with or without leading zeros, e.g. "00614" or 614.
Is internally converted to an integer.
Use NA (the default from |
exactmatch |
Logical passed to |
mindex |
Single object: Index with metadata passed to |
failempty |
Fail if no matching station is found in |
findex |
Single object: Index used to select filename, as returned by
|
current |
Single logical when |
base |
Single char: main directory of DWD ftp server.
Must be the same |
meta |
Logical: select Beschreibung file from |
quiet |
Suppress id length warnings? DEFAULT: FALSE through |
... |
Further arguments passed to |
Value
Character string with file path and name(s) in the format "base/res/var/per/filename.zip"
Author(s)
Berry Boessenkool, berry-b@gmx.de, Oct 2016, rewritten May 2022
See Also
dataDWD()
, metaIndex
,
website station selection chapter
Examples
# Give weather station name (must exist in metaIndex):
selectDWD("Potsdam", res="daily", var="kl", per="historical")
# all files for all stations matching "Koeln":
tail(selectDWD("Koeln", res="", var="", per="", exactmatch=FALSE)) # 686 files
findID("Koeln", FALSE)
## Not run: # Excluded from CRAN checks to save time
# selectDWD("Potsdam") # interactive selection of res/var/per
# directly give station ID:
selectDWD(id="00386", res="daily", var="kl", per="historical")
selectDWD(id=537, "", "", "", "") # 8 files
# period can be abbreviated:
selectDWD(id="5419", res="daily", var="kl", per="h")
# selectDWD is vectorizable!
# since version 1.5.28 (2022-05-12) outer product, not elementwise comparison:
selectDWD("Freiburg", res="daily", var="kl", per="rh")
selectDWD("Freiburg", res=c("daily","monthly"), var="kl", per="r")
selectDWD("Freiburg", res=c("daily","monthly"), var="kl", per="hr")
# get old behaviour (needed e.g. in nearbyStations):
ids <- c(3761,3761, 3603)
# all combinations:
selectDWD(id=ids, res="daily", var="kl", per=c("h","r","r")) # 4
# only given combinations:
selectDWD(id=ids, res="daily", var="kl", per=c("h","r","r"), expand=FALSE) # 3
# all files in all paths matching id:
head( selectDWD(id=c(1050, 386), res="",var="",per="") ) # 277 files
# all files in a given path (if ID is empty):
head( selectDWD(id="", res="daily", var="kl", per="recent") ) # 585 files
selectDWD(id=386, res="monthly", var="kl", per="h")
# Meta data - Description and Beschreibung txt/pdf files.:
# manually select .txt (not pdf) files for automated opening with readDWD.
link <- selectDWD(res="monthly", var="kl", per="h", meta=TRUE) # omit ID/Name!
link
link2 <- grep("\\.txt$", link, value=TRUE) ; link2
m <- dataDWD(link2, dir=locdir())
head(m)
#
# Open PDF files with your system's default Viewer:
dataDWD(link[1], dir=locdir())
## End(Not run)