Read all variables from a netCDF file

read_vars_from_cdf(vardef, vars = as.character(c()), offset = NULL,
  count = NULL, extra_dims = NULL, as.data.frame = FALSE)

Arguments

vardef

A variable definition, constructed using the following syntax: <filename>::<variables_or_bands> where <variables_or_bands> is a comma-separated list of band numbers or variable names.

A limited amount of transformation can be specified by adding extra characters to the band number or variable name:

  • Variables can be renamed by appending ->new_var_name

  • Data can be transformed by appending transformations such as @negate@fill0

A complete example is: PETmE_freq_trgt201701.img::1@fill0@negate->Neg_PETmE

In this example, band 1 is read from the file. NODATA values are replaced with zero, and all values are negated. The values are read into a variable called Neg_PETmE.

vars

A list of variables to read. If NULL (default), all variables will be read.

offset

Specifies dimension-wise (X, Y, ...) offsets from the upper-left corner of the raster (xmin, ymax) from which reading should begin. A value of c(1,1) refers to the corner cell itself (i.e., there is no offset). This follows the convention of the ncdf4 package. If offset is specified, then count must also be specified.

count

Specifies dimension-wise (X, Y, ...) numbers of cells to read, beginning at the origin cell specified by offset. A value of -1 signifies that all values after the origin cell should be read. If count is specified, then origin must also be specified.

extra_dims

list containing names and values of extra dimensions along which a values at a single point should be extracted, e.g. extra_dims=list(crop='maize', quantile=0.50). It provides a higher-abstraction alternative to the use of offset and count.

as.data.frame

return data in a data frame

Value

structure described in read_vars, or a data frame