rdwd (version 1.4.0)

readDWD.nc: 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 R.utils::gunzip(), see readDWD.raster(). DEFAULT: NULL

var

if toraster=FALSE: Charstring with name of variable to be read with ncdf4::ncvar_get(). If not available, an interactive selection is presented. DEFAULT: "" (last variable)

toraster

Read file with raster::brick()? All further arguments will be ignored. Specify e.g. var through … as varname. DEFAULT: TRUE

quiet

Logical: Suppress Suppress subfunction name message and time conversion failure warning? DEFAULT: FALSE through rdwdquiet()

Further arguments passed to raster::brick() or ncdf4::nc_open()

Value

raster::brick() object. Alternatively, if toraster=FALSE, a list with time, lat, lon, var, varname, file and cdf. cdf is the output of ncdf4::nc_open().

See Also

readDWD()

Examples

Run this code
# 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=localtestdir(), read=FALSE)
nc <- readDWD(file)
ncp <- plotRadar(nc, main=paste(nc@title, nc@z[[1]]), layer=1:3,
                 col=seqPal(), proj="nc", extent="nc")
str(nc, max.level=2)

raster::values(nc[[1]]) # obtain actual values into memory

raster::plot(nc[[1]]) # axes 0:938 / 0:720, the number of grid cells
raster::plot(ncp[[1]])# properly projected, per default onto latlon

rng <- range(raster::cellStats(nc[[1:6]], "range"))
raster::plot(nc, col=seqPal(), zlim=rng, maxnl=6)

# Array instead of raster brick:
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, var="-") # uncommented to not block automated tests
str(nc$var)
# }

Run the code above in your browser using DataLab