16 - use case: daily radar files
Update the package first:
rdwd::updateRdwd()
Download and read with readDWD.radar
with dividebyten=TRUE
:
# library("rdwd")
radbase <- paste0(gridbase,"/daily/radolan/recent/bin/")
radfile <- format(Sys.Date()-5, "raa01-sf_10000-%y%m%d1450-dwd---bin.gz")
rad <- dataDWD(radfile, base=radbase, joinbf=TRUE)
Project and then plot:
radp <- projectRasterDWD(rad$dat)
plotRadar(radp, main=paste("mm in 24 hours preceding", rad$meta$date), project=FALSE)
Save the projected radar image as NCDF file, read back and plot (not executed):
terra::writeCDF(radp, "rad_0714_2350.nc", overwrite=TRUE,
varname="pre", longname="precipitation24hrs", zname="nbands")
nc <- ncdf4::nc_open("rad_0714_2350.nc")
nc
pre <- ncdf4::ncvar_get(nc, "pre")
lon <- nc$dim$longitude$vals
lat <- nc$dim$latitude$vals
image(lon, rev(lat), pre[,ncol(pre):1]) # takes several seconds
rdwd::addBorders()