readDWD.asc: read dwd gridded radolan asc data

View source: R/readDWD.R

readDWD.ascR Documentation

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 terra raster with terra::rast().
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? See readDWD. If dividebyten=FALSE and exdir left at NULL (tempdir), save the result on disc with terra::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 terra::rast()

Value

data.frame

Author(s)

Berry Boessenkool, berry-b@gmx.de, April 2019

See Also

readDWD()

Examples

## 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)

brry/rdwd documentation built on Oct. 1, 2023, 4:15 a.m.