readDWD.nc {rdwd} | R Documentation |
read dwd netcdf data
Description
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.
Usage
readDWD.nc(
file,
gargs = NULL,
var = "",
toraster = TRUE,
quiet = rdwdquiet(),
...
)
Arguments
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 |
Value
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()
.
Author(s)
Berry Boessenkool, berry-b@gmx.de, Aug 2019
See Also
Examples
## 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)