23 - use case: derived data

This needs rdwd >= 1.5.3 (2021-06-01)

https://opendata.dwd.de/climate_environment/CDC/derived_germany/soil/daily/historical/

dbase <- "ftp://opendata.dwd.de/climate_environment/CDC/derived_germany"
soilIndex <- indexFTP(folder="soil/daily", base=dbase, dir=locdir())
soilIndex <- createIndex(soilIndex, base=dbase, dir=locdir())

#  "res" and "var" are inverted in the derived_germany folder!
colnames(soilIndex)[1:2] <- c("var", "res")
# non-standard column order, but rdwd should always use names (not positions)

head(soilIndex)
varresperidstartendismetapath
soildailyhistoricalTRUEsoil/daily/historical/AMBAV.pdf
soildailyhistoricalTRUEsoil/daily/historical/AMBETI.pdf
soildailyhistoricalTRUEsoil/daily/historical/BESCHREIBUNG_derivgermany_soil_daily_historical_de.pdf
soildailyhistorical1001FALSEsoil/daily/historical/derived_germany_soil_daily_historical_1001.txt.gz
soildailyhistorical1048FALSEsoil/daily/historical/derived_germany_soil_daily_historical_1048.txt.gz
soildailyhistorical1050FALSEsoil/daily/historical/derived_germany_soil_daily_historical_1050.txt.gz
summary(soilIndex$id)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##      44    1691    3379    3853    5349   19172      12
# select URL:
soil_link <- selectDWD("Potsdam", res="", var="", per="",
                       base=dbase, findex=soilIndex)
# Add monthly data:
soilIndexm <- indexFTP(folder="soil/monthly", base=dbase, dir=locdir())
soilIndexm <- createIndex(soilIndexm, base=dbase, dir=locdir())
soil_link <- c(soil_link, selectDWD("Potsdam", res="", var="", per="",
                                    base=dbase, findex=soilIndexm))

# download and read files:
soil_data <- dataDWD(soil_link, base=dbase, dir=locdir())
# later reading runs are much faster because unzipping is already done :)

To get files for all stations, use the following:

dbase <- "ftp://opendata.dwd.de/climate_environment/CDC/derived_germany"
soil_index <- indexFTP(folder="soil/daily", base=dbase, dir=locdir())
soil_index <- createIndex(soil_index, base=dbase, dir=locdir())
soil_links <- selectDWD(res="soil", var="daily", per="r", base=dbase, findex=soil_index)
soil_data <- dataDWD(soil_links, base=dbase, dir=locdir())