Title: | Select and Download Climate Data from 'DWD' (German Weather Service) |
---|---|
Description: | Handle climate data from the 'DWD' ('Deutscher Wetterdienst', see <https://www.dwd.de/EN/climate_environment/cdc/cdc_node_en.html> for more information). Choose observational time series from meteorological stations with 'selectDWD()'. Find raster data from radar and interpolation according to <https://bookdown.org/brry/rdwd/raster-data.html>. Download (multiple) data sets with progress bars and no re-downloads through 'dataDWD()'. Read both tabular observational data and binary gridded datasets with 'readDWD()'. |
Authors: | Berry Boessenkool [aut, cre] |
Maintainer: | Berry Boessenkool <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.8.14 |
Built: | 2024-10-29 06:03:47 UTC |
Source: | https://github.com/brry/rdwd |
add country and Bundesland borders to a map
addBorders(de = "grey80", eu = "black", add = TRUE, ...)
addBorders(de = "grey80", eu = "black", add = TRUE, ...)
de |
Color for Bundeslaender lines. NA to suppress. DEFAULT: "grey80" |
eu |
Color for countries lines. NA to suppress. DEFAULT: "black" |
add |
Logical: add to existing plot? DEFAULT: TRUE |
... |
Further arguments passed to |
# Use the SpatVectors directly with: DEU <- terra::vect(system.file("extdata/DEU.gpkg", package="rdwd")) EUR <- terra::vect(system.file("extdata/EUR.gpkg", package="rdwd")) # Obtained with the code: url <- "https://gisco-services.ec.europa.eu/distribution/v2/nuts/shp/NUTS_RG_03M_2021_4326_LEVL_1.shp.zip" tf <- tempfile(fileext=".zip") download.file(url, tf) # 0.9 MB # in 2023-06 error 'Transferred a partial file' unzip(tf, exdir="misc/vign") ; rm(url, tf) DEU <- terra::vect("misc/vign/NUTS_RG_03M_2021_4326_LEVL_1.shp") library(terra) # for bracket method DEU <- DEU[DEU$CNTR_CODE=="DE","NUTS_NAME"] terra::writeVector(DEU, "inst/extdata/DEU.gpkg", overwrite=TRUE) url <- "https://gisco-services.ec.europa.eu/distribution/v2/nuts/shp/NUTS_RG_03M_2021_4326_LEVL_0.shp.zip" tf <- tempfile(fileext=".zip") download.file(url, tf) # 0.7 MB # in 2023-06 error 'Transferred a partial file' unzip(tf, exdir="misc/vign") ; rm(url, tf) EUR <- terra::vect("misc/vign/NUTS_RG_03M_2021_4326_LEVL_0.shp") EUR <- terra::crop(EUR, c(-11,25, 40,60)) EUR <- EUR[,"NUTS_NAME"] terra::writeVector(EUR, "inst/extdata/EUR.gpkg", overwrite=TRUE)
invisible list with DEU and EUR
Berry Boessenkool, [email protected], Aug 2019, June 2023
plotRadar
, website raster chapter
if(requireNamespace("terra", quietly=TRUE)){ plot(1, xlim=c(2,16), ylim=c(47,55)) addBorders() addBorders(add=FALSE) plot(1, xlim=c(2,16), ylim=c(47,55)) addBorders(de="orange", eu=NA) }
if(requireNamespace("terra", quietly=TRUE)){ plot(1, xlim=c(2,16), ylim=c(47,55)) addBorders() addBorders(add=FALSE) plot(1, xlim=c(2,16), ylim=c(47,55)) addBorders(de="orange", eu=NA) }
Launch interactive analysis of weather period comparison for different RDWD stations. The R session is blocked during usage, close the app to re-enable console usage.
app(...)
app(...)
... |
Arguments passed to |
Berry Boessenkool, [email protected], July 2018 + April 2023
# app()
# app()
check indexes. Mainly for internal usage in createIndex()
.
Not exported, so call it as rdwd:::checkIndex() if you want to
run tests yourself. Further test suggestions are welcome!
checkIndex( findex = NULL, mindex = NULL, gindex = NULL, excludefp = TRUE, fast = FALSE, warn = !quiet, logfile = berryFunctions::packagePath(file = "misc/ExampleTests/warnings.txt"), quiet = rdwdquiet() )
checkIndex( findex = NULL, mindex = NULL, gindex = NULL, excludefp = TRUE, fast = FALSE, warn = !quiet, logfile = berryFunctions::packagePath(file = "misc/ExampleTests/warnings.txt"), quiet = rdwdquiet() )
findex |
|
mindex |
|
gindex |
|
excludefp |
Exclude false positives from geoIndex coordinate check results? DEFAULT: TRUE |
fast |
Exclude the 3-minute location per ID check? DEFAULT: FALSE |
warn |
Warn about issues? DEFAULT: |
logfile |
File to copy log to, appended to existing content. NULL to suppress. DEFAULT: "misc/ExampleTests/warnings.txt" |
quiet |
Logical: Suppress progress messages?
DEFAULT: FALSE through |
Charstring with issues (if any) to be printed with cat()
.
Berry Boessenkool, [email protected], May 2019
data(fileIndex) ; data(metaIndex) ; data(geoIndex) # ci <- rdwd:::checkIndex(findex=fileIndex, mindex=metaIndex, gindex=geoIndex) # cat(ci)
data(fileIndex) ; data(metaIndex) ; data(geoIndex) # ci <- rdwd:::checkIndex(findex=fileIndex, mindex=metaIndex, gindex=geoIndex) # cat(ci)
check suggested package for availability, yielding an instructive error message if not
checkSuggestedPackage(package, functionname)
checkSuggestedPackage(package, functionname)
package |
Charstring: package to be checked for loadability |
functionname |
Charstring: function name to be used in the message |
invisible success logical value from requireNamespace()
Berry Boessenkool, [email protected], Aug 2019
This is mainly an internal function.
Create data.frames out of the vector index returned by indexFTP()
.
For fileIndex
(the first output element) createIndex
tries to obtain res, var, per, file, id, start and end from the paths.
If meta=TRUE
, metaIndex
and geoIndex
are also
created. They combine all Beschreibung files into a single data.frame.
If you create your own index as suggested in selectDWD (argument findex
),
you can read the produced file as shown in the example section.
createIndex( paths, base = dwdbase, dir = "DWDdata", fname = "fileIndex.txt", meta = FALSE, metadir = "meta", mname = "metaIndex.txt", gname = "geoIndex.txt", overwrite = FALSE, checkwarn = TRUE, checklog = tempfile(), quiet = rdwdquiet(), ... )
createIndex( paths, base = dwdbase, dir = "DWDdata", fname = "fileIndex.txt", meta = FALSE, metadir = "meta", mname = "metaIndex.txt", gname = "geoIndex.txt", overwrite = FALSE, checkwarn = TRUE, checklog = tempfile(), quiet = rdwdquiet(), ... )
paths |
Char: vector of DWD paths returned by |
base |
Main directory of DWD ftp server, defaulting to observed climatic records.
DEFAULT: |
dir |
Char: writeable directory name where to save the main output(s).
Created if not existent. DEFAULT: "DWDdata" at current |
fname |
Char: Name of file in |
meta |
Logical: should metaIndex also be created from fileIndex?
Uses |
metadir |
Char: Directory (subfolder of |
mname |
Char: Name of file in |
gname |
Filename for |
overwrite |
Logical: Overwrite existing |
checkwarn |
Logical: warn about |
checklog |
Logfile for |
quiet |
Logical: Suppress messages about progress and filenames?
DEFAULT: FALSE through |
... |
Further arguments passed to |
invisible data.frame (or if meta=TRUE, list with two data.frames) with a number of columns inferred from the paths. Each is also written to disc.
Berry Boessenkool, [email protected], Oct-Nov 2016, June 2017
indexFTP()
, updateIndexes()
, index
, selectDWD()
,
website index chapter
## Not run: # Not tested with R CMD check because of file writing link <- "daily/kl/historical/tageswerte_KL_00699_19490101_19580630_hist.zip" ind <- createIndex(link, dir=tempdir()) ind # res var per id start end ismeta # daily kl historical 699 1949-01-01 1958-06-30 FALSE link2 <- "daily/kl/historical/KL_Tageswerte_Beschreibung_Stationen.txt" link3 <- "daily/kl/recent/KL_Tageswerte_Beschreibung_Stationen.txt" ind2 <- createIndex(c(link,link2,link3), dir=tempdir(), meta=TRUE, checkwarn=FALSE) lapply(ind2, head) link4 <- "1_minute/precipitation/meta_data/Meta_Daten_ein_min_rr_00755.zip" ind <- createIndex(link4, dir=tempdir()) ind ## End(Not run)
## Not run: # Not tested with R CMD check because of file writing link <- "daily/kl/historical/tageswerte_KL_00699_19490101_19580630_hist.zip" ind <- createIndex(link, dir=tempdir()) ind # res var per id start end ismeta # daily kl historical 699 1949-01-01 1958-06-30 FALSE link2 <- "daily/kl/historical/KL_Tageswerte_Beschreibung_Stationen.txt" link3 <- "daily/kl/recent/KL_Tageswerte_Beschreibung_Stationen.txt" ind2 <- createIndex(c(link,link2,link3), dir=tempdir(), meta=TRUE, checkwarn=FALSE) lapply(ind2, head) link4 <- "1_minute/precipitation/meta_data/Meta_Daten_ein_min_rr_00755.zip" ind <- createIndex(link4, dir=tempdir()) ind ## End(Not run)
Get climate data from the German Weather Service (DWD) FTP-server.
The desired dataset is downloaded into dir
.
If read=TRUE
, it is also read and processed.dataDWD
handles vectors of URLs,
displays progress bars (if the package pbapply
is available)
and by default does not re-download data already in dir
(but see argument force
to update files).
To solve "errors in download.file: cannot open URL", see
https://bookdown.org/brry/rdwd/fileindex.html.
dataDWD( url, base = dwdbase, joinbf = FALSE, dir = locdir(), force = FALSE, overwrite = !isFALSE(force), read = TRUE, dbin = TRUE, method = getOption("download.file.method"), dfargs = NULL, sleep = 0, progbar = !quiet, browse = FALSE, ntrunc = 2, file = NULL, quiet = rdwdquiet(), ... )
dataDWD( url, base = dwdbase, joinbf = FALSE, dir = locdir(), force = FALSE, overwrite = !isFALSE(force), read = TRUE, dbin = TRUE, method = getOption("download.file.method"), dfargs = NULL, sleep = 0, progbar = !quiet, browse = FALSE, ntrunc = 2, file = NULL, quiet = rdwdquiet(), ... )
url |
Char (vector): complete file URL(s) (including base and filename.zip)
as returned by |
base |
Single char: base URL that will be removed from output file names.
DEFAULT: |
joinbf |
Logical: paste |
dir |
Char: Writeable directory name where to save the downloaded file.
Created if not existent. DEFAULT: |
force |
Logical (vector): always download, even if the file already exists in |
overwrite |
Logical (vector): if force=TRUE, overwrite the existing file
rather than append "_1"/"_2" etc to the filename?
DEFAULT: |
read |
Logical: read the file(s) with |
dbin |
Logical: Download binary file, i.e. add |
method |
download.file |
dfargs |
Named list of additional arguments passed to |
sleep |
Number. If not 0, a random number of seconds between 0 and
|
progbar |
Logical: present a progress bar with estimated remaining time?
If missing and length(file)==1, progbar is internally set to FALSE.
Only works if the R package |
browse |
Logical: open repository via |
ntrunc |
Single integer: number of filenames printed in messages before they get truncated with message "(and xx more)". DEFAULT: 2 |
file |
Deprecated since rdwd version 1.3.34, 2020-07-28. |
quiet |
Logical: suppress message about directory / filenames?
DEFAULT: FALSE through |
... |
Further arguments passed to |
Presuming downloading and processing were successful:
if read=TRUE
, the desired dataset
(as returned by readDWD()
),
otherwise the filename as saved on disc
(may have "_n" appended in name, see berryFunctions::newFilename()
).
If length(file)>1, the output is a list of outputs / vector of filenames.
The output is always invisible.
Berry Boessenkool, [email protected], Jun-Oct 2016
selectDWD()
. readDWD()
, download.file()
.
https://bookdown.org/brry/rdwd
Helpful for plotting: berryFunctions::monthAxis()
,
see also berryFunctions::climateGraph()
## Not run: ## requires internet connection # find FTP files for a given station name and file path: link <- selectDWD("Fuerstenzell", res="hourly", var="wind", per="recent") # download file: fname <- dataDWD(link, dir=locdir(), read=FALSE) ; fname # dir="DWDdata" is the default directory to store files # unless force=TRUE, already obtained files will not be downloaded again # read and plot file: wind <- readDWD(fname, varnames=TRUE) ; head(wind) metafiles <- readMeta(fname) ; str(metafiles, max.level=1) column_names <- readVars(fname) ; head(column_names) plot(wind$MESS_DATUM, wind$F, main="DWD hourly wind Fuerstenzell", col="blue", xaxt="n", las=1, type="l", xlab="Date", ylab="Hourly Wind speed [m/s]") berryFunctions::monthAxis(1) # current and historical files, keep historical in the overlap time period: link <- selectDWD("Potsdam", res="daily", var="kl", per="hr"); link potsdam <- dataDWD(link, dir=locdir(), hr=4) plot(TMK~MESS_DATUM, data=tail(potsdam,1500), type="l") # With many files (>>50), use sleep to avoid getting kicked off the FTP server #links <- selectDWD(res="daily", var="solar") #sol <- dataDWD(links, sleep=20) # random waiting time after download (0 to 20 secs) # Real life examples can be found in the use cases section of the vignette: # browseURL("https://bookdown.org/brry/rdwd") ## End(Not run)
## Not run: ## requires internet connection # find FTP files for a given station name and file path: link <- selectDWD("Fuerstenzell", res="hourly", var="wind", per="recent") # download file: fname <- dataDWD(link, dir=locdir(), read=FALSE) ; fname # dir="DWDdata" is the default directory to store files # unless force=TRUE, already obtained files will not be downloaded again # read and plot file: wind <- readDWD(fname, varnames=TRUE) ; head(wind) metafiles <- readMeta(fname) ; str(metafiles, max.level=1) column_names <- readVars(fname) ; head(column_names) plot(wind$MESS_DATUM, wind$F, main="DWD hourly wind Fuerstenzell", col="blue", xaxt="n", las=1, type="l", xlab="Date", ylab="Hourly Wind speed [m/s]") berryFunctions::monthAxis(1) # current and historical files, keep historical in the overlap time period: link <- selectDWD("Potsdam", res="daily", var="kl", per="hr"); link potsdam <- dataDWD(link, dir=locdir(), hr=4) plot(TMK~MESS_DATUM, data=tail(potsdam,1500), type="l") # With many files (>>50), use sleep to avoid getting kicked off the FTP server #links <- selectDWD(res="daily", var="solar") #sol <- dataDWD(links, sleep=20) # random waiting time after download (0 to 20 secs) # Real life examples can be found in the use cases section of the vignette: # browseURL("https://bookdown.org/brry/rdwd") ## End(Not run)
Manage directories with useful messages in the rdwd package.
dirDWD(dir = "DWDdata", quiet = rdwdquiet())
dirDWD(dir = "DWDdata", quiet = rdwdquiet())
dir |
Char for dirDWD: writeable directory name. Created if not existent.
DEFAULT: "DWDdata" at current |
quiet |
Logical: Suppress messages about creating dir? DEFAULT: FALSE through |
dirDWD invisibly returns the prior working directory as per setwd()
.
Berry Boessenkool, [email protected], Oct 2016
# see source code of dataDWD and metaDWD
# see source code of dataDWD and metaDWD
base URLs to the DWD FTP Serverdwdbase
: observed climatic records at ftp:// variant of
https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/
See overview of available datasets
and usage suggestions.gridbase
: spatially interpolated gridded data at ftp:// variant of
https://opendata.dwd.de/climate_environment/CDC/grids_germany/
See usage suggestions
dwdbase
dwdbase
An object of class character
of length 1.
Short German parameter explanations for the DWD abbreviations
on the CDC FTP server.
These are manually created by me and might need to be expanded if the DWD adds
more abbreviations.readVars()
maps them to the variable abbreviations in the
"Metadaten_Parameter.*txt"
file in any given zip folder
and will warn about missing entries.
dwdparams
dwdparams
An object of class data.frame
with 176 rows and 2 columns.
Berry Boessenkool, [email protected], Jun 2018
head(dwdparams)
head(dwdparams)
determine which subfunction to call in readDWD()
from the file extension (ext).
The first block is for observational data (overview),
the second for gridded data (overview).
Click on the type
for the subfunction documentation, e.g. data for readDWD.data()
.
type | ext | notes |
data | .zip | For regular data at dwdbase . |
meta | .txt | For Beschreibung.txt files. For zip files containing station meta information, see readMeta() . |
multia | [SO] | [SO]: file ends with "Standort.txt" or contains multi_annual. Overrides meta . |
stand | [SF] | [SF]: file contains "standard_format". For subdaily/standard_format files. |
data | .txt.gz | For data at /CDC/derived_germany/. |
only opens file in default viewer. |
||
------- | ||
radar | .gz | For when the file contains a single binary file. |
binary | .tar.gz | The common radolan format, as far as I can tell. |
raster | .asc.gz | E.g. for seasonal data at gridbase . |
nc | .nc.gz | For packed netcdf files. |
hyras | .nc | For non-packed netcdf files. |
asc | .tar | For a file containing asc files. |
rklim | YW*.tar | For a file containing bin files. |
grib2 | .grib2.bz2 | For an nwp forecast file . |
fileType(file)
fileType(file)
file |
Filename(s) with extension. |
Character (vector)
Berry Boessenkool, [email protected], Jul 2020
ft <- read.table(header=TRUE, stringsAsFactors=FALSE, text=" type filename data daily_kl_recent_tageswerte_KL_03987_akt.zip meta daily_kl_recent_KL_Tageswerte_Beschreibung_Stationen.txt multia multi_annual_mean_81-10_Temperatur_1981-2010_aktStandort.txt multia multi_annual_mean_81-10_Temperatur_1981-2010.txt stand subdaily_standard_format_kl_10381_00_akt.txt deriv derived_germany_soil_daily_historical_3987.txt.gz pdf DESCRIPTION_obsgermany_climate_monthly_kl_historical_en.pdf radar radolan_recent_bin_raa01-rw_10000-1802020250-dwd---bin.gz binary daily_radolan_historical_bin_2017_SF201712.tar.gz raster 16_DJF_grids_germany_seasonal_air_temp_mean_188216.asc.gz nc daily_Project_TRY_humidity_RH_199509_daymean.nc.gz hyras monthly_hyras_de_humidity_hurs_hyras_5_2020_v5-0_de_monmean.nc asc radolan_historical_asc_2018_RW-201809.tar rklim 5_minutes_radolan_reproc_2017_002_bin_2020_YW2017.002_202006.tar grib2 ftp_weather_nwp_cosmo-d2_005_T_2M.grib2.bz2 grib2 Project_TRY_air_temperature_mean_TT_201102.nc.bz2 ") fileType(ft$filename) stopifnot(fileType(ft$filename)==ft$type) berryFunctions::is.error(fileType("random_stuff.odt"), force=TRUE) stopifnot(validFileTypes %in% ft$type) stopifnot(ft$type %in% validFileTypes)
ft <- read.table(header=TRUE, stringsAsFactors=FALSE, text=" type filename data daily_kl_recent_tageswerte_KL_03987_akt.zip meta daily_kl_recent_KL_Tageswerte_Beschreibung_Stationen.txt multia multi_annual_mean_81-10_Temperatur_1981-2010_aktStandort.txt multia multi_annual_mean_81-10_Temperatur_1981-2010.txt stand subdaily_standard_format_kl_10381_00_akt.txt deriv derived_germany_soil_daily_historical_3987.txt.gz pdf DESCRIPTION_obsgermany_climate_monthly_kl_historical_en.pdf radar radolan_recent_bin_raa01-rw_10000-1802020250-dwd---bin.gz binary daily_radolan_historical_bin_2017_SF201712.tar.gz raster 16_DJF_grids_germany_seasonal_air_temp_mean_188216.asc.gz nc daily_Project_TRY_humidity_RH_199509_daymean.nc.gz hyras monthly_hyras_de_humidity_hurs_hyras_5_2020_v5-0_de_monmean.nc asc radolan_historical_asc_2018_RW-201809.tar rklim 5_minutes_radolan_reproc_2017_002_bin_2020_YW2017.002_202006.tar grib2 ftp_weather_nwp_cosmo-d2_005_T_2M.grib2.bz2 grib2 Project_TRY_air_temperature_mean_TT_201102.nc.bz2 ") fileType(ft$filename) stopifnot(fileType(ft$filename)==ft$type) berryFunctions::is.error(fileType("random_stuff.odt"), force=TRUE) stopifnot(validFileTypes %in% ft$type) stopifnot(ft$type %in% validFileTypes)
Identify DWD weather station ID from station name
findID( name = "", exactmatch = TRUE, mindex = metaIndex, failempty = FALSE, quiet = rdwdquiet() )
findID( name = "", exactmatch = TRUE, mindex = metaIndex, failempty = FALSE, quiet = rdwdquiet() )
name |
Char: station name(s) that will be matched in |
exactmatch |
Logical: Should |
mindex |
Single object: Index used to select |
failempty |
Logical: fail if no matching names are found
(instead of returning NA with a warning)?
With the latter, |
quiet |
Logical: suppress length warnings? DEFAULT: FALSE through |
Character string (vector) with ID(s)
Berry Boessenkool, [email protected], Oct-Nov 2016
used in selectDWD()
, metaInfo()
# Give weather station name (must be existing in metaIndex): findID("Potsdam") findID("potsDam") # capitalization is ignored # all names containing "Hamburg": findID("Hamburg", exactmatch=FALSE) findID("Potsdam", exactmatch=FALSE) # vectorized: findID(c("Potsdam","Berlin-Buch")) # German Umlauts are changed to ue, ae, oe, ss findID("Muenchen", FALSE) berryFunctions::convertUmlaut("M?nchen") # use this to convert umlauts in lists
# Give weather station name (must be existing in metaIndex): findID("Potsdam") findID("potsDam") # capitalization is ignored # all names containing "Hamburg": findID("Hamburg", exactmatch=FALSE) findID("Potsdam", exactmatch=FALSE) # vectorized: findID(c("Potsdam","Berlin-Buch")) # German Umlauts are changed to ue, ae, oe, ss findID("Muenchen", FALSE) berryFunctions::convertUmlaut("M?nchen") # use this to convert umlauts in lists
Created with indexFTP()
and createIndex()
used in updateIndexes()
.
In functions, you can access them with rdwd:::fileIndex
etc.
fileIndex: A data.frame with the filenames (and derived information)
at the default base
value dwdbase
.
metaIndex: A data.frame with the contents of all the station description files
(..._Beschreibung_Stationen.txt) under dwdbase
.
geoIndex: metaIndex
distilled to geographic locations.
gridIndex: Vector of file paths at gridbase
.
formatIndex: (modified) table from
https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/subdaily/standard_format/formate_kl.html
fileIndex: data.frame with character strings. ca 260k rows x 8 columns:res
, var
, per
(see selectDWD()
),
station id
, time series start
and end
, and
ismeta
information, all according to path
.
metaIndex: data.frame with ca 97k rows for 12 columns:Stations_id, von_datum, bis_datum, Stationshoehe, geoBreite, geoLaenge, Stationsname, Bundesland, res, var, per, hasfile
geoIndex: data.frame with ca 6k rows for 11 columns:id, name, state, lat, lon, ele, nfiles, nonpublic, recentfile, display, col
gridIndex: Vector with ca 50k file paths at gridbase
formatIndex: data.frame with 140 rows for 12 columns:Ke_Ind, Kennung, Label, Beschreibung, Einheit, Code-Tabellen, Zusatzinfo, Typ, Pos, Erlaubt, Fehlk, dividebyten
Berry Boessenkool, [email protected], June-Nov 2016, June 2017, Oct 2019
Deutscher WetterDienst / Climate Data Center FTP Server
createIndex()
, indexFTP()
, selectDWD()
,
findID()
, metaInfo()
,
website index chapter
data(fileIndex) data(metaIndex) data(geoIndex) head(fileIndex) head(metaIndex) head(geoIndex) # in functions, you can use head(rdwd:::fileIndex) etc, but I don't export them # because Hadley says 'Never @export a data set' in # browseURL("http://r-pkgs.had.co.nz/data.html#data-data") # To use a custom index, see # browseURL("https://bookdown.org/brry/rdwd/fileindex.html")
data(fileIndex) data(metaIndex) data(geoIndex) head(fileIndex) head(metaIndex) head(geoIndex) # in functions, you can use head(rdwd:::fileIndex) etc, but I don't export them # because Hadley says 'Never @export a data set' in # browseURL("http://r-pkgs.had.co.nz/data.html#data-data") # To use a custom index, see # browseURL("https://bookdown.org/brry/rdwd/fileindex.html")
Create a list of all the files (in all subfolders) of an FTP server.
Defaults to the German Weather Service (DWD, Deutscher WetterDienst) OpenData server at
https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/.
The R package RCurl
must be available to do this.
It's not suggested to run this for all folders, as it can take quite some time
and you may get kicked off the FTP-Server. This package contains an index
of the climatic observations at weather stations (fileIndex
)
and gridded datasets (gridIndex
).
If they are out of date, please let me know!
Getting banned from the FTP Server
Normally, this shouldn't happen anymore: since Version 0.10.10 (2018-11-26),
a single RCurl handle is used for all FTP requests and since version 1.0.17 (2019-05-14),
the file tree provided by the DWD is used to obtain all folders first,
eliminating the recursive calls.
There's a provision if the FTP server detects bot requests and denies access.
If RCurl::getURL()
fails, there will still be an output
which you can pass in a second run via folder
to extract the remaining dirs.
You might need to wait a bit and set sleep
to a higher value in that case.
Here's an example:
gridindex <- indexFTP("", gridbase) gridindex <- indexFTP(gridindex, gridbase, sleep=15)
Of course, with a higher sleep value, the execution will take longer!
indexFTP( folder = "currentfindex", base = dwdbase, is.file.if.has.dot = TRUE, exclude.latest.bin = TRUE, fast = TRUE, sleep = 0, dir = "DWDdata", filename = folder[1], overwrite = FALSE, quiet = rdwdquiet(), progbar = !quiet, verbose = FALSE )
indexFTP( folder = "currentfindex", base = dwdbase, is.file.if.has.dot = TRUE, exclude.latest.bin = TRUE, fast = TRUE, sleep = 0, dir = "DWDdata", filename = folder[1], overwrite = FALSE, quiet = rdwdquiet(), progbar = !quiet, verbose = FALSE )
folder |
Folder(s) to be indexed recursively, e.g. "/hourly/wind/".
Leading slashes will be removed.
Use |
base |
Main directory of FTP server. Trailing slashes will be removed.
DEFAULT: |
is.file.if.has.dot |
Logical: if some of the input paths contain a dot, treat those as files, i.e. do not try to read those as if they were a folder. Only set this to FALSE if you know what you're doing. DEFAULT: TRUE |
exclude.latest.bin |
Exclude latest file at opendata.dwd.de/weather/radar/radolan? RCurl::getURL indicates this is a pointer to the last regularly named file. DEFAULT: TRUE |
fast |
Read tree file with |
sleep |
If not 0, a random number of seconds between 0 and |
dir |
Writeable directory name where to save the downloaded file.
Created if not existent.
DEFAULT: "DWDdata" at current |
filename |
Character: Part of output filename. "INDEX_of_DWD_" is prepended, "/" replaced with "_", ".txt" appended. DEFAULT: folder[1] |
overwrite |
Logical: Overwrite existing file? If not, "_n" is added to the
filename, see |
quiet |
Suppress progbars and message about directory/files?
DEFAULT: FALSE through |
progbar |
Logical: present a progress bar in each level? DEFAULT: TRUE |
verbose |
Logical: write a lot of messages from |
a vector with file paths
Berry Boessenkool, [email protected], Oct 2016
createIndex()
, updateIndexes()
,
website index chapter
## Not run: ## Needs internet connection sol <- indexFTP(folder="/daily/solar", dir=tempdir()) head(sol) # mon <- indexFTP(folder="/monthly/kl", dir=tempdir(), verbose=TRUE) ## End(Not run)
## Not run: ## Needs internet connection sol <- indexFTP(folder="/daily/solar", dir=tempdir()) head(sol) # mon <- indexFTP(folder="/monthly/kl", dir=tempdir(), verbose=TRUE) ## End(Not run)
Great-circle distance between points at lat-long coordinates. Mostly a copy of OSMscale::earthDist Version 0.5.3 (2017-04-19). https://github.com/brry/OSMscale/blob/master/R/earthDist.R#L57-L102. Copied manually to avoid dependency hell. Does not check coordinates. Not exported.
lldist(lat, long, data, r = 6371, i = 1L) maxlldist(lat, long, data, r = 6371, fun = max, each = TRUE, ...)
lldist(lat, long, data, r = 6371, i = 1L) maxlldist(lat, long, data, r = 6371, fun = max, each = TRUE, ...)
lat , long
|
Latitude (North/South) and longitude (East/West) coordinates in decimal degrees |
data |
Optional: data.frame with the columns |
r |
radius of the earth. Could be given in miles. DEFAULT: 6371 (km) |
i |
Integer: Index element against which all coordinate pairs are computed. DEFAULT: 1 |
fun |
Function to be applied. DEFAULT: |
each |
Logical: give max dist to all other points for each point separately?
If FALSE, will return the maximum of the complete distance matrix,
as if |
... |
Further arguments passed to fun, like na.rm=TRUE |
Vector with distance(s) in km (or units of r
, if r
is changed)
Berry Boessenkool, [email protected], Aug 2016 + Jan 2017. Angle formula from Diercke Weltatlas 1996, Page 245
This can be used to set a directory for DWD data across projects,
thus avoiding multiple downloads of the same file.
Set the default for all subsequent calls with options(rdwdlocdir="YOUR/PATH")
.
You could add this to your .Rprofile file e.g. via usethis::edit_r_profile()
locdir(dir = getOption("rdwdlocdir"), file = NULL, quiet = rdwdquiet())
locdir(dir = getOption("rdwdlocdir"), file = NULL, quiet = rdwdquiet())
dir |
Path to data directory.
If |
file |
Optional: path(s) at |
quiet |
Logical: suppress tempdir warning?
DEFAULT: FALSE through |
charstring (directory)
Berry Boessenkool, [email protected], Apr 2019, Jun 2021
locdir() oldopt <- options(rdwdlocdir="~") locdir() stopifnot(locdir() == path.expand("~")) options(oldopt) ; rm(oldopt)
locdir() oldopt <- options(rdwdlocdir="~") locdir() stopifnot(locdir() == path.expand("~")) options(oldopt) ; rm(oldopt)
Information for a station ID on the DWD CDC FTP server
metaInfo(id, mindex = metaIndex, hasfileonly = TRUE)
metaInfo(id, mindex = metaIndex, hasfileonly = TRUE)
id |
Station ID (integer number or convertible to one) |
mindex |
Index dataframe with metadata. DEFAULT: |
hasfileonly |
Logical: Only show entries that have files? DEFAULT: TRUE |
invisible data.frame. Also prints
the output nicely formatted.
Berry Boessenkool, [email protected], Nov 2016
metaInfo(2849)
metaInfo(2849)
Select DWD stations within a given radius around a set of coordinates
nearbyStations( lat, lon, radius, res = NA, var = NA, per = NA, mindate = NA, hasfileonly = TRUE, statname = "nearbyStations target location", quiet = rdwdquiet(), ... )
nearbyStations( lat, lon, radius, res = NA, var = NA, per = NA, mindate = NA, hasfileonly = TRUE, statname = "nearbyStations target location", quiet = rdwdquiet(), ... )
lat |
Coordinates y component [degrees N/S, range 47:55] |
lon |
Coordinates x component [degrees E/W, range 6:15] |
radius |
Maximum distance [km] within which stations will be selected |
res , var , per
|
Restrictions for dataset type as documented in
|
mindate |
Minimum dataset ending date (as per metadata). DEFAULT: NA |
hasfileonly |
Logical: only return entries for which there is an open-access file available? DEFAULT: TRUE |
statname |
Character: name for target location. DEFAULT: "nearbyStations target location" |
quiet |
Logical: suppress progress messages? DEFAULT: FALSE through |
... |
Further arguments passed to |
metaIndex
subset with additional columns "dist" and "url"
Berry Boessenkool, [email protected], Mar 2017
selectDWD()
, metaIndex
,
website use case with nearbyStations
m <- nearbyStations(49.211784, 9.812475, radius=30, res=c("daily","hourly"), var= c("precipitation","more_precip","kl") , mindate=as.Date("2016-05-30"), statname="Braunsbach catchment center") # View(m) # for a continued example of this, see the vignette in chapter # use case: plot all rainfall values around a given point # browseURL("https://bookdown.org/brry/rdwd")
m <- nearbyStations(49.211784, 9.812475, radius=30, res=c("daily","hourly"), var= c("precipitation","more_precip","kl") , mindate=as.Date("2016-05-30"), statname="Braunsbach catchment center") # View(m) # for a continued example of this, see the vignette in chapter # use case: plot all rainfall values around a given point # browseURL("https://bookdown.org/brry/rdwd")
Add short German parameter descriptions to the DWD abbreviations.
This uses dwdparams()
to create column names like
"TT_TU.Lufttemperatur" and "RSK.Niederschlagshoehe."
Column names not in the abbreviation list will be left untouched.
newColumnNames(dataframe, variables = dwdparams, separator = ".")
newColumnNames(dataframe, variables = dwdparams, separator = ".")
dataframe |
Dataframe as returned by |
variables |
Dataframe as returned by |
separator |
Separator between abbreviation and long name. DEFAULT: "." |
The dataframe
with new column names
Berry Boessenkool, [email protected], Apr 2019
dwdparams
, readVars()
, readDWD()
argument varnames
, newColumnNames()
# mainly for internal usage
# mainly for internal usage
plot rdwd time series from data.frames
plotDWD( x, cn, monthaxis = TRUE, line0 = FALSE, xlab = "", ylab = cn, main = "", type = "l", lwd = 3, col = "blue", las = 1, mar = c(2.6, 3.1, 2.5, 0.5), mgp = c(1.9, 0.7, 0), keeppar = TRUE, ... )
plotDWD( x, cn, monthaxis = TRUE, line0 = FALSE, xlab = "", ylab = cn, main = "", type = "l", lwd = 3, col = "blue", las = 1, mar = c(2.6, 3.1, 2.5, 0.5), mgp = c(1.9, 0.7, 0), keeppar = TRUE, ... )
x |
Data.frame, e.g. from readDWD.data |
cn |
Column name (charstring) |
monthaxis |
Draw nice axis? DEFAULT: TRUE |
line0 |
Draw horizontal line at 0? DEFAULT: FALSE |
xlab |
X axis label. DEFAULT: "" |
ylab |
Y axis label. DEFAULT: cn |
main |
Plot title. DEFAULT: "" |
type |
graphics::plot type. DEFAULT: "l" |
lwd |
Line width. DEFAULT: 3 |
col |
Line color. DEFAULT: "blue" |
las |
Label axis style. DEFAULT: 1 (all upright) |
mar |
Plot margins. DEFAULT: c(2.6, 3.1, 2.5, 0.5) |
mgp |
Margin placement. DEFAULT: c(1.9, 0.7, 0) |
keeppar |
Keep |
... |
Further arguments passed to graphics::plot |
Nothing
Berry Boessenkool, [email protected], Sep 2021
link <- selectDWD("Potsdam", res="daily", var="kl", per="r") clim <- dataDWD(link, dir=locdir(), varnames=TRUE) plotDWD(clim, "TMK.Lufttemperatur", line0=TRUE, main="Potsdam")
link <- selectDWD("Potsdam", res="daily", var="kl", per="r") clim <- dataDWD(link, dir=locdir(), varnames=TRUE) plotDWD(clim, "TMK.Lufttemperatur", line0=TRUE, main="Potsdam")
Convenience function to plot radar products on a pretty map. Creates a separate plot for each layer, a selection is possible.
plotRadar( x, layer = NULL, main = names(x), land = "gray80", sea = "cadetblue1", de = "grey80", eu = "black", col = berryFunctions::seqPal(), xlim = NULL, ylim = NULL, zlim = NULL, axes = TRUE, las = 1, mar = c(2.5, 3.5, 2.5, 5), keeppar = TRUE, project = TRUE, proj = "radolan", extent = "radolan", adjust05 = FALSE, targetproj = "ll", quiet = rdwdquiet(), ... )
plotRadar( x, layer = NULL, main = names(x), land = "gray80", sea = "cadetblue1", de = "grey80", eu = "black", col = berryFunctions::seqPal(), xlim = NULL, ylim = NULL, zlim = NULL, axes = TRUE, las = 1, mar = c(2.5, 3.5, 2.5, 5), keeppar = TRUE, project = TRUE, proj = "radolan", extent = "radolan", adjust05 = FALSE, targetproj = "ll", quiet = rdwdquiet(), ... )
x |
terra raster oject, e.g. 'dat' element of object returned by |
layer |
Optional: selected layer(s) to be plotted. DEFAULT: NULL |
main |
Graph title(s). Use "" to suppress. DEFAULT: names(x) |
land |
Color of land areas in the map. DEFAULT: "gray80" |
sea |
Color of sea areas in the map. DEFAULT: "cadetblue1" |
de |
Color of Deutschland Bundesland borders. DEFAULT: "grey80" |
eu |
Color of Europe country borders . DEFAULT: "black" |
col |
Color palette for the data itself.
DEFAULT: |
xlim |
xlim. DEFAULT: NULL, i.e. taken from x extent (after reprojection if |
ylim |
ylim. DEFAULT: NULL, i.e. taken from y extent (after reprojection if |
zlim |
zlim. 3 Options: two-number vector,
|
axes |
Draw axes? DEFAULT: TRUE |
las |
LabelAxisStyle for axes. DEFAULT: 1 (all upright) |
mar |
Vector with plot margins. DEFAULT: c(2.5, 3.5, 2.5, 5) |
keeppar |
Logical: keep the margins set with par, so later points etc are
added in the right location?
DEFAULT: TRUE, opposite to |
project |
Project the data before plotting? Not needed if
|
proj |
current projection, see |
extent |
current extent, see |
adjust05 |
Logical: Adjust extent by 0.5m to match edges? DEFAULT: FALSE |
targetproj |
target projection, see |
quiet |
suppress progress messages? DEFAULT: FALSE through |
... |
Further arguments passed to |
terra object, (re)projected (if project=TRUE
).
If length(layer)==1
, only that selected layer is returned.
Berry Boessenkool, [email protected], Feb 2020, June 2023
projectRasterDWD()
, addBorders()
, readDWD()
,
website raster chapter
# See https://bookdown.org/brry/rdwd/raster-data.html ## Not run: ## Excluded from CRAN checks: requires internet connection link <- "seasonal/air_temperature_mean/16_DJF/grids_germany_seasonal_air_temp_mean_188216.asc.gz" rad <- dataDWD(link, base=gridbase, joinbf=TRUE) radp <- plotRadar(rad, proj="seasonal", extent=NULL, main="plotRadar ex") plotRadar(radp, ylim=c(52,54), project=FALSE) # plotRadar equivalent, map only country borders: radpm <- projectRasterDWD(rad[[1]], proj="seasonal", extent=NULL) terra::plot(radpm) addBorders() # several layers url <- "daily/Project_TRY/pressure/PRED_199606_daymean.nc.gz" # 5 MB nc <- dataDWD(url, base=gridbase, joinbf=TRUE) ncp3 <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1:3, col=terrain.colors(100), proj="nc", extent="nc") plotRadar(ncp3, layer=3:4, project=FALSE) # still has all layers plotRadar(ncp3, layer=4:5, project=FALSE, zlim="ind") # individual zlims per layer plotRadar(ncp3, layer=1, project=FALSE, zlim=c(1016,1020)) ncp1 <- plotRadar(nc, layer=1, proj="nc", extent="nc") # much faster projection # no longer has layers 2-4: berryFunctions::is.error(plotRadar(ncp1, layer=1:4, project=FALSE), TRUE, TRUE) ## End(Not run)
# See https://bookdown.org/brry/rdwd/raster-data.html ## Not run: ## Excluded from CRAN checks: requires internet connection link <- "seasonal/air_temperature_mean/16_DJF/grids_germany_seasonal_air_temp_mean_188216.asc.gz" rad <- dataDWD(link, base=gridbase, joinbf=TRUE) radp <- plotRadar(rad, proj="seasonal", extent=NULL, main="plotRadar ex") plotRadar(radp, ylim=c(52,54), project=FALSE) # plotRadar equivalent, map only country borders: radpm <- projectRasterDWD(rad[[1]], proj="seasonal", extent=NULL) terra::plot(radpm) addBorders() # several layers url <- "daily/Project_TRY/pressure/PRED_199606_daymean.nc.gz" # 5 MB nc <- dataDWD(url, base=gridbase, joinbf=TRUE) ncp3 <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1:3, col=terrain.colors(100), proj="nc", extent="nc") plotRadar(ncp3, layer=3:4, project=FALSE) # still has all layers plotRadar(ncp3, layer=4:5, project=FALSE, zlim="ind") # individual zlims per layer plotRadar(ncp3, layer=1, project=FALSE, zlim=c(1016,1020)) ncp1 <- plotRadar(nc, layer=1, proj="nc", extent="nc") # much faster projection # no longer has layers 2-4: berryFunctions::is.error(plotRadar(ncp1, layer=1:4, project=FALSE), TRUE, TRUE) ## End(Not run)
Set projection and extent for DWD raster data. Optionally (and
per default) also reprojects to latlon data.
WARNING: reprojection to latlon changes values slightly. For the
tested RX product, this change is significant, see:
https://github.com/brry/rdwd/blob/master/misc/ExampleTests/Radartests.pdf
In terra::plot, use range=zlim with the original range if needed.
projectRasterDWD( r, proj = "radolan", extent = "radolan", adjust05 = FALSE, targetproj = "ll", threads = TRUE, quiet = rdwdquiet() )
projectRasterDWD( r, proj = "radolan", extent = "radolan", adjust05 = FALSE, targetproj = "ll", threads = TRUE, quiet = rdwdquiet() )
r |
terra raster object |
proj |
Current projection to be given to |
extent |
Current |
adjust05 |
Logical: Adjust extent by 0.5m to match edges? DEFAULT: FALSE |
targetproj |
|
threads |
Use multiple CPU threads for |
quiet |
Logical: suppress progress messages? DEFAULT: FALSE through |
The internal defaults are extracted from the Kompositformatbeschreibung at
https://www.dwd.de/DE/leistungen/radolan/radolan.html, as provided
2019-04 by Antonia Hengst.
The nc extent was obtained by projecting
Germanys bbox to EPSG 3034 (specified in the DWD documentation). Using that
as a starting point, I then refined the extent to a visual match, see
developmentNotes.R
terra raster object with projection and extent, invisible
Berry Boessenkool, [email protected], May 2019, June 2023
plotRadar()
terra::
crs
/ ext
/ project
readDWD.
binary
/ raster
/
asc
/ radar
/ nc
website raster chapter
# To be used after readDWD.binary etc
# To be used after readDWD.binary etc
find, select, download + read data from the German weather service DWD
vectorized, progress bars, no re-downloads
index of files + meta data
observational time series from 6k meteorological recording stations (2.5k active)
-> rain, temperature, wind, sunshine, pressure, cloudiness, humidity, snow, ...
gridded raster data from radar + interpolation
european data stock slowly growing
For an introduction to the package, see https://bookdown.org/brry/rdwd.
Berry Boessenkool, [email protected]
Useful links:
Report bugs at https://github.com/brry/rdwd/issues
global quiet option. The default rdwdquiet()
is FALSE
.
Just write the following in your code and all subsequent calls will be quiet:options(rdwdquiet=TRUE)
rdwdquiet()
rdwdquiet()
Read climate data that was downloaded with dataDWD()
.
The data is unzipped and subsequently, the file(s) are read, processed and
returned as a data.frame / terra raster object.
For observational data, new users are advised to set varnames=TRUE
to obtain more informative column names.readDWD
will call internal (but documented) subfunctions depending on the
argument type
, see the overview in fileType()
.
Not all arguments to readDWD
are used for all subfunctions, e.g.
fread
is used only by readDWD.data
, while dividebyten
is used in readDWD.raster
and readDWD.asc
.file
can be a vector with several filenames. Most other arguments can
also be a vector and will be recycled to the length of file
.
readDWD( file, type = fileType(file), varnames = FALSE, fread = NA, format = NA, tz = "GMT", hr = 0, dividebyten = TRUE, var = "", progbar = !quiet, quiet = rdwdquiet(), quietread = quiet, ... )
readDWD( file, type = fileType(file), varnames = FALSE, fread = NA, format = NA, tz = "GMT", hr = 0, dividebyten = TRUE, var = "", progbar = !quiet, quiet = rdwdquiet(), quietread = quiet, ... )
file |
Char (vector): name(s) of the file(s) downloaded with
|
type |
Character (vector) determining which subfunction to call.
DEFAULT: |
varnames |
Logical (vector): Expand column names?
Only used in |
fread |
Logical (vector): read fast? Used in |
format , tz
|
Format and time zone of time stamps, see |
hr |
Integer code to merge historical and recent file.
Used here, but documented in detail in |
dividebyten |
Logical (vector): Divide the values in raster files by ten?
That way, [1/10 mm] gets transformed to [mm] units.
Used in |
var |
var for |
progbar |
Logical: present a progress bar with estimated remaining time? If missing and length(file)==1, progbar is internally set to FALSE, unless binary files are to be read. DEFAULT: !quiet |
quiet |
Logical: suppress messages? DEFAULT: FALSE through |
quietread |
Logical: suppress message like
"Reading 1 file with readDWD.data() and fread=TRUE ...".
DEFAULT: |
... |
Further arguments passed to the internal |
For observational data, an invisible data.frame of the desired dataset,
or a named list of data.frames if length(file) > 1.
For gridded data, terra raster objects.
Berry Boessenkool, [email protected], Jul-Oct 2016, Winter 2018/19
dataDWD()
, readVars()
, readMeta()
, selectDWD()
, fileType()
https://bookdown.org/brry/rdwd
# see dataDWD and readDWD.* subfunctions
# see dataDWD and readDWD.* subfunctions
read grid-interpolated radolan asc data.
Intended to be called via readDWD()
.
All layers (following selection
if given) in all .tar.gz files are
combined into a terra raster with terra::rast()
.
To project the data, use projectRasterDWD()
readDWD.asc( file, exdir = NULL, dividebyten = TRUE, selection = NULL, quiet = rdwdquiet(), progbar = !quiet, ... )
readDWD.asc( file, exdir = NULL, dividebyten = TRUE, selection = NULL, quiet = rdwdquiet(), progbar = !quiet, ... )
file |
Name of file on harddrive, like e.g.
DWDdata/grids_germany/hourly/radolan/historical/asc/
2018_RW-201809.tar.
Must have been downloaded with |
exdir |
Directory to unzip into. Unpacked files existing therein
will not be untarred again, saving up to 15 secs per file.
DEFAULT: NULL (subfolder of |
dividebyten |
Divide numerical values by 10? See readDWD.
If dividebyten=FALSE and exdir left at NULL (tempdir), save
the result on disc with |
selection |
Optionally read only a subset of the ~24*31=744 files.
Called as |
quiet |
Suppress progress messages?
DEFAULT: FALSE through |
progbar |
Show progress bars? |
... |
Further arguments passed to |
data.frame
Berry Boessenkool, [email protected], April 2019
## Not run: # Excluded from CRAN checks, but run in localtests # File selection and download: radbase <- paste0(gridbase,"/hourly/radolan/historical/asc/") radfile <- "2018/RW-201809.tar" # 25 MB to download file <- dataDWD(radfile, base=radbase, joinbf=TRUE, read=FALSE) #asc <- readDWD(file) # 4 GB in mem. ~ 20 secs unzip, 10 secs read, 2 min divide asc <- readDWD(file, selection=1:5, dividebyten=TRUE) plotRadar(asc[[1]], main=names(asc)[1]) viddir <- paste0(tempdir(),"/RadolanVideo") dir.create(viddir) png(paste0(viddir,"/Radolan_%03d.png"), width=7, height=5, units="in", res=300) plotRadar(asc, layer=1:3, main=names(asc)) # 3 secs per layer dev.off() berryFunctions::openFile(paste0(viddir,"/Radolan_001.png")) # Time series of a given point in space: plot(unlist(asc[800,800,]), type="l", xlab="Time [hours]") # if dividebyten=FALSE, terra stores things out of memory in the exdir. # by default, this is in tempdir, hence you would need to save asc manually: # terra::writeRaster(asc, tempfile(fileext="/RW2018-09.gpkg"), overwrite=TRUE) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests # File selection and download: radbase <- paste0(gridbase,"/hourly/radolan/historical/asc/") radfile <- "2018/RW-201809.tar" # 25 MB to download file <- dataDWD(radfile, base=radbase, joinbf=TRUE, read=FALSE) #asc <- readDWD(file) # 4 GB in mem. ~ 20 secs unzip, 10 secs read, 2 min divide asc <- readDWD(file, selection=1:5, dividebyten=TRUE) plotRadar(asc[[1]], main=names(asc)[1]) viddir <- paste0(tempdir(),"/RadolanVideo") dir.create(viddir) png(paste0(viddir,"/Radolan_%03d.png"), width=7, height=5, units="in", res=300) plotRadar(asc, layer=1:3, main=names(asc)) # 3 secs per layer dev.off() berryFunctions::openFile(paste0(viddir,"/Radolan_001.png")) # Time series of a given point in space: plot(unlist(asc[800,800,]), type="l", xlab="Time [hours]") # if dividebyten=FALSE, terra stores things out of memory in the exdir. # by default, this is in tempdir, hence you would need to save asc manually: # terra::writeRaster(asc, tempfile(fileext="/RW2018-09.gpkg"), overwrite=TRUE) ## End(Not run)
read gridded radolan binary data.
Intended to be called via readDWD()
.
readDWD.binary( file, exdir = sub(".tar.gz$", "", file), toraster = TRUE, quiet = rdwdquiet(), progbar = !quiet, selection = NULL, ... )
readDWD.binary( file, exdir = sub(".tar.gz$", "", file), toraster = TRUE, quiet = rdwdquiet(), progbar = !quiet, selection = NULL, ... )
file |
Name of file on harddrive, like e.g. DWDdata/daily_radolan_historical_bin_2017_SF201712.tar.gz |
exdir |
Directory to unzip into. If existing, only the needed files
will be unpacked with |
toraster |
Logical: convert output (list of matrixes + meta informations)
to a list with dat ( |
quiet |
Suppress progress messages?
DEFAULT: FALSE through |
progbar |
Show progress bars? |
selection |
Optionally read only a subset of the ~24*31=744 files.
Called as |
... |
Further arguments passed to |
list depending on argument toraster
, see there for details
Berry Boessenkool, [email protected], Dec 2018.
Significant input for the underlying dwdradar::readRadarFile()
came
from Henning Rust & Christoph Ritschel at FU Berlin.
readDWD()
, especially readDWD.radar()
https://wradlib.org for much more extensive radar analysis in Python
Kompositformatbeschreibung at https://www.dwd.de/DE/leistungen/radolan/radolan.html
for format description
## Not run: # Excluded from CRAN checks, but run in localtests # SF file as example: ---- SF_link <- "/daily/radolan/historical/bin/2017/SF201712.tar.gz" SF_file <- dataDWD(url=SF_link, base=gridbase, joinbf=TRUE, # 204 MB dir=locdir(), read=FALSE) # exdir radardir set to speed up my tests: SF_exdir <- "C:/Users/berry/Desktop/DWDbinarySF" if(!file.exists(SF_exdir)) SF_exdir <- tempdir() # no need to read all 24*31=744 files, so setting selection: SF_rad <- readDWD(SF_file, selection=1:10, exdir=SF_exdir) #with toraster=TRUE if(length(SF_rad)!=2) stop("length(SF_rad) should be 2, but is ", length(SF_rad)) SF_radp <- plotRadar(SF_rad$dat, layer=1:3, main=SF_rad$meta$date) plotRadar(SF_radp, layer=1, project=FALSE) # RW file as example: ---- RW_link <- "hourly/radolan/reproc/2017_002/bin/2017/RW2017.002_201712.tar.gz" RW_file <- dataDWD(url=RW_link, base=gridbase, joinbf=TRUE, # 25 MB dir=locdir(), read=FALSE) RW_exdir <- "C:/Users/berry/Desktop/DWDbinaryRW" if(!file.exists(RW_exdir)) RW_exdir <- tempdir() RW_rad <- readDWD(RW_file, selection=1:10, exdir=RW_exdir) RW_radp <- plotRadar(RW_rad$dat[[1]], main=RW_rad$meta$date[1], extent="rw") # ToDo: why are values + patterns not the same? # list of all Files: ---- data(gridIndex) head(grep("historical", gridIndex, value=TRUE)) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests # SF file as example: ---- SF_link <- "/daily/radolan/historical/bin/2017/SF201712.tar.gz" SF_file <- dataDWD(url=SF_link, base=gridbase, joinbf=TRUE, # 204 MB dir=locdir(), read=FALSE) # exdir radardir set to speed up my tests: SF_exdir <- "C:/Users/berry/Desktop/DWDbinarySF" if(!file.exists(SF_exdir)) SF_exdir <- tempdir() # no need to read all 24*31=744 files, so setting selection: SF_rad <- readDWD(SF_file, selection=1:10, exdir=SF_exdir) #with toraster=TRUE if(length(SF_rad)!=2) stop("length(SF_rad) should be 2, but is ", length(SF_rad)) SF_radp <- plotRadar(SF_rad$dat, layer=1:3, main=SF_rad$meta$date) plotRadar(SF_radp, layer=1, project=FALSE) # RW file as example: ---- RW_link <- "hourly/radolan/reproc/2017_002/bin/2017/RW2017.002_201712.tar.gz" RW_file <- dataDWD(url=RW_link, base=gridbase, joinbf=TRUE, # 25 MB dir=locdir(), read=FALSE) RW_exdir <- "C:/Users/berry/Desktop/DWDbinaryRW" if(!file.exists(RW_exdir)) RW_exdir <- tempdir() RW_rad <- readDWD(RW_file, selection=1:10, exdir=RW_exdir) RW_radp <- plotRadar(RW_rad$dat[[1]], main=RW_rad$meta$date[1], extent="rw") # ToDo: why are values + patterns not the same? # list of all Files: ---- data(gridIndex) head(grep("historical", gridIndex, value=TRUE)) ## End(Not run)
Read regular dwd data.
Intended to be called via readDWD()
.
readDWD.data( file, fread = FALSE, varnames = FALSE, format = NA, tz = "GMT", hr = 0, quiet = rdwdquiet(), ... )
readDWD.data( file, fread = FALSE, varnames = FALSE, format = NA, tz = "GMT", hr = 0, quiet = rdwdquiet(), ... )
file |
Name of file on harddrive, like e.g. DWDdata/daily_kl_recent_tageswerte_KL_03987_akt.zip |
fread |
Logical: read faster with data.table::fread?
When reading many large historical files, speedup is significant.
When called from |
varnames |
Logical (vector): add a short description to the DWD variable
abbreviations in the column names?
E.g. change |
format |
Char (vector): Format passed to |
tz |
Char (vector): time zone for |
hr |
Integer code to automatically merge historical and recent datasets.
If set, |
quiet |
Suppress empty file warnings?
DEFAULT: FALSE through |
... |
Further arguments passed to |
data.frame
Berry Boessenkool, [email protected]
readDWD()
, Examples in dataDWD()
Read dwd data from /CDC/derived_germany/.
Intended to be called via readDWD()
.
readDWD.deriv(file, gargs = NULL, todate = TRUE, quiet = rdwdquiet(), ...)
readDWD.deriv(file, gargs = NULL, todate = TRUE, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. DWDdata/soil_daily_historical_derived_germany_soil_daily_historical_3987.txt.gz |
gargs |
If fread=FALSE: Named list of arguments passed to
|
todate |
Logical: Convert char column 'Datum' or 'Monat' with |
quiet |
Ignored.
DEFAULT: FALSE through |
... |
Further arguments passed to |
data.frame
Berry Boessenkool, [email protected]
readDWD()
, https://bookdown.org/brry/rdwd/use-case-derived-data.html
read gridded numerical weather prediction data.
Intended to be called via readDWD()
.
readDWD.grib2(file, pack = "terra", bargs = NULL, quiet = rdwdquiet(), ...)
readDWD.grib2(file, pack = "terra", bargs = NULL, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. cosmo-d2_germany_regular-lat-lon_single-level_2021010100_005_T_2M.grib2.bz2 |
pack |
Char: package used for reading. One of "terra" or "stars". "rgdal" (for the deprecated cosmo-d2 data) is no longer available, see issue. DEFAULT: "terra" |
bargs |
Named list of arguments passed to
|
quiet |
Silence readGDAL completely, including warnings on
discarded ellps / datum.
DEFAULT: FALSE through |
... |
Further arguments passed to |
terra or stars object, depending on pack
Berry Boessenkool, [email protected], Jan 2021.
readDWD()
https://www.dwd.de/EN/ourservices/nwp_forecast_data/nwp_forecast_data.html
https://www.dwd.de/EN/aboutus/it/functions/Teasergroup/grib.html
## Not run: # Excluded from CRAN checks, but run in localtests nwp_t2m_base <- "ftp://opendata.dwd.de/weather/nwp/icon-d2/grib/15/soiltyp" nwp_urls <- indexFTP("", base=nwp_t2m_base, dir=tempdir()) # for p instead of soiltyp, icosahedral_model-level files fail with GDAL errors, # see https://github.com/brry/rdwd/issues/28 # regular-lat-lon_pressure-level files work with pack="terra" or "stars" nwp_file <- dataDWD(tail(nwp_urls,1), base=nwp_t2m_base, dir=tempdir(), joinbf=TRUE, dbin=TRUE, read=FALSE) nwp_data <- readDWD(nwp_file) terra::plot(nwp_data) addBorders() # the projection seems to be perfectly good :) # index of GRIB files if(FALSE){ # indexing takes about 6 minutes! grib_base <- "ftp://opendata.dwd.de/weather/nwp/icon-d2/grib" grib_files <- indexFTP("", base=grib_base, dir=tempdir()) for(f in unique(substr(grib_files, 1,3))) print(grib_files[which(substr(grib_files, 1,3)==f)[1]]) View(data.frame(grep("regular",grib_files, value=TRUE))) } # Project_TRY bz2 netcdf data: url <- "hourly/Project_TRY/air_temperature_mean/TT_201102.nc.bz2" # 97 MB file <- dataDWD(url, base=gridbase, joinbf=TRUE, dir=tempdir(), read=FALSE) nc <- readDWD(file) # should also be using readDWD.grib2 # Setting layer=1:2 takes 4 minutes, just go one at a time, I guess: ncp <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1, col=berryFunctions::seqPal(), proj="nc", extent="nc") ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests nwp_t2m_base <- "ftp://opendata.dwd.de/weather/nwp/icon-d2/grib/15/soiltyp" nwp_urls <- indexFTP("", base=nwp_t2m_base, dir=tempdir()) # for p instead of soiltyp, icosahedral_model-level files fail with GDAL errors, # see https://github.com/brry/rdwd/issues/28 # regular-lat-lon_pressure-level files work with pack="terra" or "stars" nwp_file <- dataDWD(tail(nwp_urls,1), base=nwp_t2m_base, dir=tempdir(), joinbf=TRUE, dbin=TRUE, read=FALSE) nwp_data <- readDWD(nwp_file) terra::plot(nwp_data) addBorders() # the projection seems to be perfectly good :) # index of GRIB files if(FALSE){ # indexing takes about 6 minutes! grib_base <- "ftp://opendata.dwd.de/weather/nwp/icon-d2/grib" grib_files <- indexFTP("", base=grib_base, dir=tempdir()) for(f in unique(substr(grib_files, 1,3))) print(grib_files[which(substr(grib_files, 1,3)==f)[1]]) View(data.frame(grep("regular",grib_files, value=TRUE))) } # Project_TRY bz2 netcdf data: url <- "hourly/Project_TRY/air_temperature_mean/TT_201102.nc.bz2" # 97 MB file <- dataDWD(url, base=gridbase, joinbf=TRUE, dir=tempdir(), read=FALSE) nc <- readDWD(file) # should also be using readDWD.grib2 # Setting layer=1:2 takes 4 minutes, just go one at a time, I guess: ncp <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1, col=berryFunctions::seqPal(), proj="nc", extent="nc") ## End(Not run)
Read hyras netcdf data.
Intended to be called via readDWD()
.
Note that terra
must be installed to read the .nc files.
readDWD.hyras(file, quiet = rdwdquiet(), ...)
readDWD.hyras(file, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. DWDdata/monthly_hyras_de_humidity_hurs_hyras_5_2020_v5-0_de_monmean.nc |
quiet |
Currently not used.
DEFAULT: FALSE through |
... |
Further arguments passed to |
terra::rast()
object.
Berry Boessenkool, [email protected], Jun 2023
readDWD.nc()
for packed .nc.gz files, readDWD()
## Not run: # Excluded from CRAN checks, but run in localtests link <- "monthly/hyras_de/humidity/hurs_hyras_5_2020_v5-0_de_monmean.nc" hyras <- dataDWD(link, gridbase, joinbf=TRUE) # 0.9MB plotRadar(hyras, proj="nc", extent=NULL, main=substr(terra::time(hyras),1,7), layer=1:2) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests link <- "monthly/hyras_de/humidity/hurs_hyras_5_2020_v5-0_de_monmean.nc" hyras <- dataDWD(link, gridbase, joinbf=TRUE) # 0.9MB plotRadar(hyras, proj="nc", extent=NULL, main=substr(terra::time(hyras),1,7), layer=1:2) ## End(Not run)
read dwd metadata (Beschreibung*.txt files).
Intended to be called via readDWD()
.
Column widths for read.fwf()
are computed internally.
if(any(meta)), readDWD()
tries to set the locale to German
(to handle Umlaute correctly). It is hence not recommended to call
rdwd:::readDWD.meta
directly on a file!
Names can later be changed to ascii with
berryFunctions::convertUmlaut()
.
readDWD.meta(file, quiet = rdwdquiet(), ...)
readDWD.meta(file, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. DWDdata/daily_kl_recent_KL_Tageswerte_Beschreibung_Stationen.txt |
quiet |
Ignored.
DEFAULT: FALSE through |
... |
Further arguments passed to |
data.frame
Berry Boessenkool, [email protected]
## Not run: # Excluded from CRAN checks, but run in localtests link <- selectDWD(res="daily", var="kl", per="r", meta=TRUE) link <- link[!grepl("mn4", link)] # for mn4 file May 2022 link <- grep(".txt$", link, value=TRUE) if(length(link)!=1) stop("length of link should be 1, but is ", length(link), ":\n", berryFunctions::truncMessage(link,prefix="",sep="\n")) file <- dataDWD(link, dir=locdir(), read=FALSE) meta <- readDWD(file) head(meta) cnm <- colnames(meta) if(length(cnm)!=8) stop("number of columns should be 8, but is ", length(cnm), ":\n", toString(cnm)) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests link <- selectDWD(res="daily", var="kl", per="r", meta=TRUE) link <- link[!grepl("mn4", link)] # for mn4 file May 2022 link <- grep(".txt$", link, value=TRUE) if(length(link)!=1) stop("length of link should be 1, but is ", length(link), ":\n", berryFunctions::truncMessage(link,prefix="",sep="\n")) file <- dataDWD(link, dir=locdir(), read=FALSE) meta <- readDWD(file) head(meta) cnm <- colnames(meta) if(length(cnm)!=8) stop("number of columns should be 8, but is ", length(cnm), ":\n", toString(cnm)) ## End(Not run)
read multi_annual dwd data.
Intended to be called via readDWD()
.
All other observational data at dwdbase
can be read
with readDWD.data()
, except for the multi_annual and
subdaily/standard_format data.
readDWD.multia( file, fileEncoding = "latin1", tryenc = TRUE, comment.char = "\032", quiet = rdwdquiet(), ... )
readDWD.multia( file, fileEncoding = "latin1", tryenc = TRUE, comment.char = "\032", quiet = rdwdquiet(), ... )
file |
Name of file on harddrive, like e.g. DWDdata/multi_annual_mean_81-10_Temperatur_1981-2010_aktStandort.txt or DWDdata/multi_annual_mean_81-10_Temperatur_1981-2010_Stationsliste_aktStandort.txt |
fileEncoding |
|
tryenc |
Logical. If reading fails, try with encoding ="". This was added in version 1.8.5 (2023-09-27) because of non-reproducible issues in runLocalTests. DEFAULT: TRUE |
comment.char |
|
quiet |
Ignored.
DEFAULT: FALSE through |
... |
Further arguments passed to |
data.frame
Berry Boessenkool, [email protected], Feb 2019
## Not run: # Excluded from CRAN checks, but run in localtests # Temperature aggregates (2019-04 the 9th file, 2022-05 the 8th): durl <- selectDWD(res="multi_annual", per="mean_81-10")[8] murl <- selectDWD(res="multi_annual", per="mean_81-10", meta=TRUE)[8] # encoding issue not tested enough to be in the source code: ma_temp <- dataDWD(durl) ma_meta <- dataDWD(murl) head(ma_temp) head(ma_meta) ma <- merge(ma_meta, ma_temp, all=TRUE) berryFunctions::linReg(ma$Stationshoehe, ma$Jahr, main="annual average ~ elevation") op <- par(mfrow=c(3,4), mar=c(0.1,2,2,0), mgp=c(3,0.6,0)) for(m in colnames(ma)[8:19]) { berryFunctions::linReg(ma$Stationshoehe, ma[,m], xaxt="n", xlab="", ylab="", main=m) abline(h=0) } par(op) par(bg=8) berryFunctions::colPoints(ma$geogr..Laenge, ma$geogr..Breite, ma$Jahr, add=F, asp=1.4) DEU <- terra::vect(system.file("extdata/DEU.gpkg", package="rdwd")) pdf("MultiAnn.pdf", width=8, height=10) par(bg="grey90") for(m in colnames(ma)[8:19]) { terra::plot(DEU, border="grey40") berryFunctions::colPoints(ma[-262,]$geogr..Laenge, ma[-262,]$geogr..Breite, ma[-262,m], asp=1.4, # Range=range(ma[-262,8:19]), col=berryFunctions::divPal(200, rev=TRUE), zlab=m, add=T) } dev.off() berryFunctions::openFile("MultiAnn.pdf") ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests # Temperature aggregates (2019-04 the 9th file, 2022-05 the 8th): durl <- selectDWD(res="multi_annual", per="mean_81-10")[8] murl <- selectDWD(res="multi_annual", per="mean_81-10", meta=TRUE)[8] # encoding issue not tested enough to be in the source code: ma_temp <- dataDWD(durl) ma_meta <- dataDWD(murl) head(ma_temp) head(ma_meta) ma <- merge(ma_meta, ma_temp, all=TRUE) berryFunctions::linReg(ma$Stationshoehe, ma$Jahr, main="annual average ~ elevation") op <- par(mfrow=c(3,4), mar=c(0.1,2,2,0), mgp=c(3,0.6,0)) for(m in colnames(ma)[8:19]) { berryFunctions::linReg(ma$Stationshoehe, ma[,m], xaxt="n", xlab="", ylab="", main=m) abline(h=0) } par(op) par(bg=8) berryFunctions::colPoints(ma$geogr..Laenge, ma$geogr..Breite, ma$Jahr, add=F, asp=1.4) DEU <- terra::vect(system.file("extdata/DEU.gpkg", package="rdwd")) pdf("MultiAnn.pdf", width=8, height=10) par(bg="grey90") for(m in colnames(ma)[8:19]) { terra::plot(DEU, border="grey40") berryFunctions::colPoints(ma[-262,]$geogr..Laenge, ma[-262,]$geogr..Breite, ma[-262,m], asp=1.4, # Range=range(ma[-262,8:19]), col=berryFunctions::divPal(200, rev=TRUE), zlab=m, add=T) } dev.off() berryFunctions::openFile("MultiAnn.pdf") ## End(Not run)
Read netcdf data.
Intended to be called via readDWD()
.
Note that R.utils
and ncdf4
must be installed to unzip and read the .nc.gz files.
readDWD.nc( file, gargs = NULL, var = "", toraster = TRUE, quiet = rdwdquiet(), ... )
readDWD.nc( file, gargs = NULL, var = "", toraster = TRUE, quiet = rdwdquiet(), ... )
file |
Name of file on harddrive, like e.g. DWDdata/grids_germany/daily/Project_TRY/humidity/RH_199509_daymean.nc.gz |
gargs |
Named list of arguments passed to
|
var |
if toraster=FALSE: Charstring with name of variable to be read with
|
toraster |
Read file with |
quiet |
Logical: Suppress time conversion failure warning?
DEFAULT: FALSE through |
... |
Further arguments passed to |
terra::rast()
object. Alternatively,
if toraster=FALSE, a list with time, lat, lon, var, varname, file and cdf.
cdf is the output of ncdf4::nc_open()
.
Berry Boessenkool, [email protected], Aug 2019
readDWD.hyras()
for non-packed .nc files, readDWD()
## Not run: # Excluded from CRAN checks, but run in localtests library(berryFunctions) # for seqPal and colPointsLegend url <- "daily/Project_TRY/pressure/PRED_199606_daymean.nc.gz" # 5 MB url <- "daily/Project_TRY/humidity/RH_199509_daymean.nc.gz" # 25 MB file <- dataDWD(url, base=gridbase, joinbf=TRUE, dir=locdir(), read=FALSE) nc <- readDWD(file) ncp <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1:3, col=seqPal(), proj="nc", extent="nc") str(terra::values(nc[[1]])) # obtain actual values into memory terra::plot(nc[[1]]) # axes 0:938 / 0:720, the number of grid cells terra::plot(ncp[[1]])# properly projected, per default onto latlon rng <- range(terra::global(nc[[1:6]], "range", na.rm=TRUE)) terra::plot(nc, col=seqPal(), zlim=rng, maxnl=6) # Array instead of terra rast: nc <- readDWD(file, toraster=FALSE) image(nc$var[,,1], col=seqPal(), asp=1.1) colPointsLegend(nc$var[,,1], title=paste(nc$varname, nc$time[1])) # interactive selection of variable: # nc <- readDWD(file, toraster=FALSE, var="-") # commented out to not block automated tests str(nc$var) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests library(berryFunctions) # for seqPal and colPointsLegend url <- "daily/Project_TRY/pressure/PRED_199606_daymean.nc.gz" # 5 MB url <- "daily/Project_TRY/humidity/RH_199509_daymean.nc.gz" # 25 MB file <- dataDWD(url, base=gridbase, joinbf=TRUE, dir=locdir(), read=FALSE) nc <- readDWD(file) ncp <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1:3, col=seqPal(), proj="nc", extent="nc") str(terra::values(nc[[1]])) # obtain actual values into memory terra::plot(nc[[1]]) # axes 0:938 / 0:720, the number of grid cells terra::plot(ncp[[1]])# properly projected, per default onto latlon rng <- range(terra::global(nc[[1:6]], "range", na.rm=TRUE)) terra::plot(nc, col=seqPal(), zlim=rng, maxnl=6) # Array instead of terra rast: nc <- readDWD(file, toraster=FALSE) image(nc$var[,,1], col=seqPal(), asp=1.1) colPointsLegend(nc$var[,,1], title=paste(nc$varname, nc$time[1])) # interactive selection of variable: # nc <- readDWD(file, toraster=FALSE, var="-") # commented out to not block automated tests str(nc$var) ## End(Not run)
open pdf file. This leads to less failures in the new meta=TRUE
readDWD.pdf(file, quiet = rdwdquiet(), ...)
readDWD.pdf(file, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. monthly_kl_historical_DESCRIPTION_obsgermany_climate_monthly_kl_historical_en.pdf |
quiet |
Ignored. DEFAULT: FALSE through |
... |
Further arguments passed to |
berryFunctions::openFile()
output
selectDWD()
.Intended to be called via readDWD()
.
Berry Boessenkool, [email protected], May 2022.
## Not run: # Excluded from CRAN checks, but run in localtests link <- selectDWD(res="hourly", var="solar", per="r", meta=TRUE) if(!any(endsWith(link,"pdf"))) stop("no pdf file here anymore") # hourly/sun no longer has a pdf file anymore 2023-09 link <- link[endsWith(link,"pdf")][1] file <- dataDWD(link, read=FALSE) readDWD(file) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests link <- selectDWD(res="hourly", var="solar", per="r", meta=TRUE) if(!any(endsWith(link,"pdf"))) stop("no pdf file here anymore") # hourly/sun no longer has a pdf file anymore 2023-09 link <- link[endsWith(link,"pdf")][1] file <- dataDWD(link, read=FALSE) readDWD(file) ## End(Not run)
read gridded radolan radar data.
Intended to be called via readDWD()
.
readDWD.radar( file, gargs = NULL, toraster = TRUE, dividebyten = TRUE, quiet = rdwdquiet(), ... )
readDWD.radar( file, gargs = NULL, toraster = TRUE, dividebyten = TRUE, quiet = rdwdquiet(), ... )
file |
Name of file on harddrive, like e.g. DWDdata/hourly/radolan/recent/bin/ raa01-rw_10000-1802020250-dwd—bin.gz |
gargs |
Named list of arguments passed to
|
toraster |
Logical: convert output (list of matrixes + meta informations)
to a list with data ( |
dividebyten |
Logical: Divide the numerical values by 10? See readDWD. toraster??? DEFAULT: TRUE |
quiet |
Ignored.
DEFAULT: FALSE through |
... |
Further arguments passed to |
Invisible list with dat
(matrix or raster, depending on toraster
)
and meta
(list with elements from header)
Berry Boessenkool, [email protected], Aug 2019.
Significant input for the underlying dwdradar::readRadarFile()
came
from Henning Rust & Christoph Ritschel at FU Berlin.
readDWD()
, especially readDWD.binary()
https://wradlib.org for much more extensive radar analysis in Python
Kompositformatbeschreibung at https://www.dwd.de/DE/leistungen/radolan/radolan.html
for format description
## Not run: # Excluded from CRAN checks, but run in localtests # recent radar files rrf <- indexFTP("hourly/radolan/recent/bin", base=gridbase, dir=tempdir()) lrf <- dataDWD(rrf[773], base=gridbase, joinbf=TRUE, dir=tempdir(), read=FALSE) r <- readDWD(lrf) plotRadar(r$dat, main=paste("mm in 24 hours preceding", r$meta$date)) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests # recent radar files rrf <- indexFTP("hourly/radolan/recent/bin", base=gridbase, dir=tempdir()) lrf <- dataDWD(rrf[773], base=gridbase, joinbf=TRUE, dir=tempdir(), read=FALSE) r <- readDWD(lrf) plotRadar(r$dat, main=paste("mm in 24 hours preceding", r$meta$date)) ## End(Not run)
Read gridded raster data.
Intended to be called via readDWD()
.
Note that R.utils
must be installed to unzip the .asc.gz files.
readDWD.raster(file, gargs = NULL, dividebyten, quiet = rdwdquiet(), ...)
readDWD.raster(file, gargs = NULL, dividebyten, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. DWDdata/grids_germany/seasonal/air_temperature_mean/ 16_DJF_grids_germany_seasonal_air_temp_mean_188216.asc.gz |
gargs |
Named list of arguments passed to |
dividebyten |
Logical: Divide the numerical values by 10? See readDWD. DEFAULT: TRUE |
quiet |
Ignored.
DEFAULT: FALSE through |
... |
Further arguments passed to |
terra::rast
object
Berry Boessenkool, [email protected], Dec 2018
## Not run: # Excluded from CRAN checks, but run in localtests rasterbase <- paste0(gridbase,"/seasonal/air_temperature_mean") ftp.files <- indexFTP("/16_DJF", base=rasterbase, dir=tempdir()) localfiles <- dataDWD(ftp.files[1:2], base=rasterbase, joinbf=TRUE, dir=locdir(), read=FALSE) rf <- readDWD(localfiles[1]) rf <- readDWD(localfiles[1]) # runs faster at second time due to skip=TRUE terra::plot(rf) plotRadar(rf, proj="seasonal", extent=NULL) testthat::expect_equal(c(terra::minmax(rf)), c(-8.2,4.4)) rf10 <- readDWD(localfiles[1], dividebyten=FALSE) terra::plot(rf10) testthat::expect_equal(c(terra::minmax(rf10*1)), c(-82,44)) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests rasterbase <- paste0(gridbase,"/seasonal/air_temperature_mean") ftp.files <- indexFTP("/16_DJF", base=rasterbase, dir=tempdir()) localfiles <- dataDWD(ftp.files[1:2], base=rasterbase, joinbf=TRUE, dir=locdir(), read=FALSE) rf <- readDWD(localfiles[1]) rf <- readDWD(localfiles[1]) # runs faster at second time due to skip=TRUE terra::plot(rf) plotRadar(rf, proj="seasonal", extent=NULL) testthat::expect_equal(c(terra::minmax(rf)), c(-8.2,4.4)) rf10 <- readDWD(localfiles[1], dividebyten=FALSE) terra::plot(rf10) testthat::expect_equal(c(terra::minmax(rf10*1)), c(-82,44)) ## End(Not run)
read gridded radklim binary data.
Intended to be called via readDWD()
.
Note: needs dwdradar >= 0.2.6 (2021-08-08)
readDWD.rklim( file, exdir = NULL, unpacked = NULL, selection = NULL, toraster = TRUE, quiet = rdwdquiet(), progbar = !quiet, ... )
readDWD.rklim( file, exdir = NULL, unpacked = NULL, selection = NULL, toraster = TRUE, quiet = rdwdquiet(), progbar = !quiet, ... )
file |
Name of file on harddrive, like e.g. DWDdata/5_minutes_radolan_reproc_2017_002_bin_2020_YW2017.002_202006.tar |
exdir |
Directory to unzip into. If existing, only the needed files
will be unpacked with |
unpacked |
Manually indicate whether .tar.gz files within .tar file have already been unpacked before. DEFAULT: NULL: checks if 'yw.*–bin' file(s) are present |
selection |
Optionally read only a subset of the ~ 12 x 24 x 30/31 = 8640 files.
Called as |
toraster |
Logical: convert to terra::rast? see readDWD.binary DEFAULT: TRUE |
quiet |
Suppress progress messages?
DEFAULT: FALSE through |
progbar |
Show progress bars? DEFAULT: !quiet, i.e. TRUE |
... |
Further arguments passed to |
list depending on argument toraster
, see there for details
Berry Boessenkool, [email protected], Aug 2021.
readDWD.binary()
, radar locations from https://www.dwd.de/DE/leistungen/radarklimatologie/radklim_kompositformat_1_0.pdf?__blob=publicationFile&v=1
## Not run: # Excluded from CRAN checks, but run in localtests yw_link <- "/5_minutes/radolan/reproc/2017_002/bin/2022/YW2017.002_202203.tar" # 202006 has untar error on Mac, 2023-04, maybe due to incomplete download yw_file <- dataDWD(url=yw_link, base=gridbase, joinbf=TRUE, read=FALSE) # 207 MB x <- readDWD(yw_file, selection=3641:3644) # 00:30 for tar files, 01:40 for unpacking. # If you need a preselection argument, let me know. terra::plot(x$dat) plotRadar(x$dat[[1]], extent="rw") # better extent below f <- system.file("tests//raa01-yw2017.002_10000-2006131525-dwd---bin", package="dwdradar") # https://stackoverflow.com/a/72207233/1587132 on how to install with tests folder if(!file.exists(f)){ # Clone from https://github.com/brry/dwdradar: f <- locdir(file="binary_testfile") download.file(paste0("https://github.com/brry/dwdradar/raw/master/tests/", "raa01-yw2017.002_10000-2006131525-dwd---bin"), f, mode="wb") } x <- dwdradar::readRadarFile(f) x$dat <- terra::rast(x$dat) terra::plot(x$dat) plotRadar(x$dat, extent=c(-360, 380, -4730 ,-3690)) radloc <- read.table(header=T, sep=",", text=" ND, NM, NS , ED, EM, ES 53, 33, 50.4, 06, 44, 53.9 51, 07, 26.5, 13, 45, 48.5 51, 24, 18.5, 06, 57, 49.8 47, 52, 21.3, 08, 00, 24.6 54, 10, 23.2, 12, 06, 25.3 52, 28, 40.3, 13, 23, 13.0 54, 00, 15.8, 10, 02, 48.7 51, 07, 28.7, 13, 46, 07.1 49, 32, 26.4, 12, 24, 10.0 53, 20, 19.4, 07, 01, 25.5 51, 24, 20.2, 06, 58, 01.6 47, 52, 25.0, 08, 00, 13.0 51, 20, 06.0, 08, 51, 09.0 51, 18, 40.3, 08, 48, 07.2 50, 03, 06.0, 08, 34, 05.0 50, 01, 20.8, 08, 33, 30.7 53, 37, 16.5, 09, 59, 47.6 52, 27, 47.0, 09, 41, 53.9 52, 27, 36.2, 09, 41, 40.2 48, 10, 28.9, 12, 06, 06.3 48, 02, 31.7, 10, 13, 09.2 48, 20, 10.9, 11, 36, 42.1 50, 30, 00.4, 11, 08, 06.2 50, 06, 34.7, 06, 32, 53.9 49, 59, 05.1, 08, 42, 46.6 52, 38, 55.2, 13, 51, 29.6 54, 10, 32.4, 12, 03, 29.1 48, 35, 07.0, 09, 46, 58.0 52, 09, 36.3, 11, 10, 33.9") radloc$x <- radloc$ED + radloc$EM/60 + radloc$ES/3600 radloc$y <- radloc$ND + radloc$NM/60 + radloc$NS/3600 for(i in 1:29) berryFunctions::circle(radloc$x[i], radloc$y[i], 0.9) ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests yw_link <- "/5_minutes/radolan/reproc/2017_002/bin/2022/YW2017.002_202203.tar" # 202006 has untar error on Mac, 2023-04, maybe due to incomplete download yw_file <- dataDWD(url=yw_link, base=gridbase, joinbf=TRUE, read=FALSE) # 207 MB x <- readDWD(yw_file, selection=3641:3644) # 00:30 for tar files, 01:40 for unpacking. # If you need a preselection argument, let me know. terra::plot(x$dat) plotRadar(x$dat[[1]], extent="rw") # better extent below f <- system.file("tests//raa01-yw2017.002_10000-2006131525-dwd---bin", package="dwdradar") # https://stackoverflow.com/a/72207233/1587132 on how to install with tests folder if(!file.exists(f)){ # Clone from https://github.com/brry/dwdradar: f <- locdir(file="binary_testfile") download.file(paste0("https://github.com/brry/dwdradar/raw/master/tests/", "raa01-yw2017.002_10000-2006131525-dwd---bin"), f, mode="wb") } x <- dwdradar::readRadarFile(f) x$dat <- terra::rast(x$dat) terra::plot(x$dat) plotRadar(x$dat, extent=c(-360, 380, -4730 ,-3690)) radloc <- read.table(header=T, sep=",", text=" ND, NM, NS , ED, EM, ES 53, 33, 50.4, 06, 44, 53.9 51, 07, 26.5, 13, 45, 48.5 51, 24, 18.5, 06, 57, 49.8 47, 52, 21.3, 08, 00, 24.6 54, 10, 23.2, 12, 06, 25.3 52, 28, 40.3, 13, 23, 13.0 54, 00, 15.8, 10, 02, 48.7 51, 07, 28.7, 13, 46, 07.1 49, 32, 26.4, 12, 24, 10.0 53, 20, 19.4, 07, 01, 25.5 51, 24, 20.2, 06, 58, 01.6 47, 52, 25.0, 08, 00, 13.0 51, 20, 06.0, 08, 51, 09.0 51, 18, 40.3, 08, 48, 07.2 50, 03, 06.0, 08, 34, 05.0 50, 01, 20.8, 08, 33, 30.7 53, 37, 16.5, 09, 59, 47.6 52, 27, 47.0, 09, 41, 53.9 52, 27, 36.2, 09, 41, 40.2 48, 10, 28.9, 12, 06, 06.3 48, 02, 31.7, 10, 13, 09.2 48, 20, 10.9, 11, 36, 42.1 50, 30, 00.4, 11, 08, 06.2 50, 06, 34.7, 06, 32, 53.9 49, 59, 05.1, 08, 42, 46.6 52, 38, 55.2, 13, 51, 29.6 54, 10, 32.4, 12, 03, 29.1 48, 35, 07.0, 09, 46, 58.0 52, 09, 36.3, 11, 10, 33.9") radloc$x <- radloc$ED + radloc$EM/60 + radloc$ES/3600 radloc$y <- radloc$ND + radloc$NM/60 + radloc$NS/3600 for(i in 1:29) berryFunctions::circle(radloc$x[i], radloc$y[i], 0.9) ## End(Not run)
read subdaily/standard_format dwd data.
Intended to be called via readDWD()
.
All other observational data at dwdbase
can be read
with readDWD.data()
, except for the multi_annual and
subdaily/standard_format data.
readDWD.stand( file, fast = TRUE, fileEncoding = "latin1", formIndex = formatIndex, quiet = rdwdquiet(), ... )
readDWD.stand( file, fast = TRUE, fileEncoding = "latin1", formIndex = formatIndex, quiet = rdwdquiet(), ... )
file |
Name of file on harddrive, like e.g. DWDdata/subdaily_standard_format_kl_10381_00_akt.txt or DWDdata/subdaily_standard_format_kl_10381_bis_1999.txt.gz |
fast |
Logical: use |
fileEncoding |
|
formIndex |
Single object: Index used to select column widts and NA values.
To use a current / custom index, see the source code of
|
quiet |
Ignored.
DEFAULT: FALSE through |
... |
Further arguments passed to |
data.frame with column names as per formatIndex
.
"Q"-columns have "_parameter" appended to their name. A "Date" column has been added.
NA-indicators have been processed into NAs.
Berry Boessenkool, [email protected], Oct 2019
## Not run: # Excluded from CRAN checks, but run in localtests link <- selectDWD(res="subdaily", var="standard_format", per="r") link <- link[grepl("10381", link, fixed=TRUE)] # Not ID, according to meta data, hence no longer in column id (2023-04). file <- dataDWD(link, dir=locdir(), read=FALSE) sf <- readDWD(file) sf2 <- readDWD(file, fast=FALSE) # 20 secs! stopifnot(all.equal(sf, sf2)) plot(sf$Date, sf$SHK, type="l") # Plot all columns: if(FALSE){ # not run in any automated testing tmp <- tempfile(fileext=".pdf") char2fact <- function(x) { if(all(is.na(x))) return(rep(-9, len=length(x))) if(!is.numeric(x)) as.factor(x) else x } pdf(tmp, width=9) par(mfrow=c(2,1),mar=c(2,3,2,0.1), mgp=c(3,0.7,0), las=1) for(i in 3:ncol(sf)-1) plot(sf$Date, char2fact(sf[,i]), type="l", main=colnames(sf)[i], ylab="") dev.off() berryFunctions::openFile(tmp) } ## End(Not run)
## Not run: # Excluded from CRAN checks, but run in localtests link <- selectDWD(res="subdaily", var="standard_format", per="r") link <- link[grepl("10381", link, fixed=TRUE)] # Not ID, according to meta data, hence no longer in column id (2023-04). file <- dataDWD(link, dir=locdir(), read=FALSE) sf <- readDWD(file) sf2 <- readDWD(file, fast=FALSE) # 20 secs! stopifnot(all.equal(sf, sf2)) plot(sf$Date, sf$SHK, type="l") # Plot all columns: if(FALSE){ # not run in any automated testing tmp <- tempfile(fileext=".pdf") char2fact <- function(x) { if(all(is.na(x))) return(rep(-9, len=length(x))) if(!is.numeric(x)) as.factor(x) else x } pdf(tmp, width=9) par(mfrow=c(2,1),mar=c(2,3,2,0.1), mgp=c(3,0.7,0), las=1) for(i in 3:ncol(sf)-1) plot(sf$Date, char2fact(sf[,i]), type="l", main=colnames(sf)[i], ylab="") dev.off() berryFunctions::openFile(tmp) } ## End(Not run)
Read climate meta info textfiles in zip folders downloaded with dataDWD()
.
readMeta(file, progbar = TRUE, ...)
readMeta(file, progbar = TRUE, ...)
file |
Char (vector): name(s) of the zip file(s) downloaded with |
progbar |
Logical: present a progress bar with estimated remaining time? If missing and length(file)==1, progbar is internally set to FALSE. DEFAULT: TRUE |
... |
Further arguments passed to |
Invisible named list of data.frames; or a list of lists, if length(file)>1.
Berry Boessenkool, [email protected], 2016 + March 2019
dataDWD()
, readVars()
, readDWD()
# see dataDWD
# see dataDWD
Read climate variables (column meta data) from zip folders downloaded with
dataDWD()
.
The metadata file "Metadaten_Parameter.*txt"
in the zip folder file
is read, processed and returned as a data.frame.file
can be a vector with several filenames.
readVars(file, params = dwdparams, quiet = rdwdquiet(), progbar = TRUE)
readVars(file, params = dwdparams, quiet = rdwdquiet(), progbar = TRUE)
file |
Char (vector): name(s) of the file(s) downloaded with |
params |
data.frame: Parameter explanations. DEFAULT: |
quiet |
Suppress message about non-abbreviated parameters?
DEFAULT: FALSE through |
progbar |
Logical: present a progress bar with estimated remaining time? If missing and length(file)==1, progbar is internally set to FALSE. DEFAULT: TRUE |
data.frame of the desired dataset, or a named list of data.frames if length(file) > 1.
Berry Boessenkool, [email protected], Jun 2018
dataDWD()
, readDWD()
, dwdparams
, newColumnNames()
readMeta()
for complete Metadaten_Parameter
file.
website use case
# see dataDWD
# see dataDWD
Create display character string for leaflet map popup from data.frame rows.
This function is not exported, as it is only internally useful.
A generic version is available in berryFunctions::popleaf()
.
rowDisplay(x)
rowDisplay(x)
x |
data.frame with colnames |
Vector of character strings, one for each row in x.
Berry Boessenkool, [email protected], Feb 2017
Run rdwd
tests on local machine. Due to time-intensive
data downloads, these tests are not run automatically on CRAN.
runLocalTests( dir_data = locdir(), dir_exmpl = berryFunctions::packagePath(file = "misc/ExampleTests"), start = 1, quiet = rdwdquiet() )
runLocalTests( dir_data = locdir(), dir_exmpl = berryFunctions::packagePath(file = "misc/ExampleTests"), start = 1, quiet = rdwdquiet() )
dir_data |
Reusable data location. Preferably not under version control.
DEFAULT: |
dir_exmpl |
Reusable example location. DEFAULT: local directory |
start |
Number to start tests at, helpful for partially successful runs. DEFAULT: 1 |
quiet |
Suppress progress messages? DEFAULT: FALSE through |
Time taken to run tests in minutes
Berry Boessenkool, [email protected], Apr-Oct 2019
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.
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(), ... )
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(), ... )
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 |
Character string with file path and name(s) in the format "base/res/var/per/filename.zip"
Berry Boessenkool, [email protected], Oct 2016, rewritten May 2022
dataDWD()
, metaIndex
,
website station selection chapter
# 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)
# 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)
Update rdwd to the latest development version on github, if necessary.
If the version number or date is larger on github,
remotes::install_github()
will be called.
updateRdwd( pack = "rdwd", user = "brry", vignette = NA, quiet = rdwdquiet(), ... )
updateRdwd( pack = "rdwd", user = "brry", vignette = NA, quiet = rdwdquiet(), ... )
pack |
Name of (already installed) package. DEFAULT: "rdwd" |
user |
Github username. repo will then be user/pack. DEFAULT: "brry" |
vignette |
build_vignettes in |
quiet |
Suppress version messages and |
... |
Further arguments passed to |
data.frame with version information
Berry Boessenkool, [email protected], Nov 2019
# updateRdwd()
# updateRdwd()
fileType values that have a reading subfunction readDWD.ftype()
.
validFileTypes
validFileTypes
An object of class character
of length 14.