rdwd (version 1.4.0)

readDWD.asc: read dwd gridded radolan asc data

Description

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 raster stack with raster::stack(). To project the data, use projectRasterDWD()

Usage

readDWD.asc(
  file,
  exdir = NULL,
  dividebyten = TRUE,
  selection = NULL,
  quiet = rdwdquiet(),
  progbar = !quiet,
  ...
)

Arguments

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 mode="wb"!

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 tempdir())

dividebyten

Divide numerical values by 10? If dividebyten=FALSE and exdir left at NULL (tempdir), save the result on disc with raster::writeRaster(). Accessing out-of-memory raster objects won't work if exdir is removed! -> Error in .local(.Object, ...) DEFAULT: TRUE

selection

Optionally read only a subset of the ~24*31=744 files. Called as f[selection]. DEFAULT: NULL (ignored)

quiet

Suppress progress messages? DEFAULT: FALSE through rdwdquiet()

progbar

Show progress bars? readDWD() will keep progbar=TRUE for asc files, even if length(file)==1. DEFAULT: !quiet, i.e. TRUE

Further arguments passed to raster::raster()

Value

data.frame

See Also

readDWD()

Examples

Run this code
# NOT RUN {
 # Excluded from CRAN checks, but run in localtests

# File selection and download:
datadir <- localtestdir()
radbase <- paste0(gridbase,"/hourly/radolan/historical/asc/")
radfile <- "2018/RW-201809.tar" # 25 MB to download
file <- dataDWD(radfile, base=radbase, joinbf=TRUE, dir=datadir,
                dbin=TRUE, read=FALSE) # download with mode=wb!!!

#asc <- readDWD(file) # 4 GB in mem. ~ 20 secs unzip, 30 secs read, 10 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(as.vector(asc[800,800,]), type="l", xlab="Time [hours]")

# if dividebyten=FALSE, raster stores things out of memory in the exdir.
# by default, this is in tempdir, hence you would need to save asc manually:
# raster::writeRaster(asc, paste0(datadir,"/RW2018-09"), overwrite=TRUE)
# }

Run the code above in your browser using DataLab