The names of the list elements will be used to name the variable associated with each matrix. Consistent with the raster package, it is assumed that matrices are stored as (lat, lon), with lon increasing and lat decreasing.

write_vars_to_cdf(vars, filename, extent = NULL, ids = NULL,
  xmin = NULL, xmax = NULL, ymin = NULL, ymax = NULL,
  extra_dims = NULL, write_slice = NULL, attrs = list(),
  prec = NULL, append = FALSE, put_data = TRUE,
  quick_append = FALSE)

Arguments

vars

List of matrices containing values to write, or a 3D with dimension names on the third dimension.

filename

Name of output file

extent

vector of (xmin, xmax, ymin, ymax)

ids

vector of integer or character IDs

xmin

lowest longitude value (left side of cell)

xmax

highest longitude value (right side of cell)

ymin

lowest latitude value (bottom of cell)

ymax

highest latitude value (top of cell)

extra_dims

Optional list of extra dimensions (excluding 'id' or spatial dimensions). Specified as a list with dimension names as keys and a vector of acceptable values as values, e.g. extra_dims=list(crop=c('maize', 'rice'), season=c('spring', 'fall'))

write_slice

Optional list used to write a two-dimensional array (lat, lon) across constant values of other dimensions. List keys are used to indicate dimension names and values are used to indicate the constant value for that dimension.

attrs

List of attributes to associate with the file, or with each variable. Each attribute is described by a list, with the following properties:

var

Variable with which the attribute is associated, or NULL for a global attribute

key

Name of the attribute

val

Value of the attribute

prec

The numerical precision with which vars should be written. Can be either a character vector, in which case the same precision will be used for all variables, or a list whose names correspond to the names of vars, specifying a precision for each variable. If vars is NULL, or a variable is not specified in a list, a default precision will be selected depending on the values. Acceptable precision descriptions include:

  • byte (8-bit signed integer)

  • short (16-bit signed integer)

  • integer (32-bit signed integer)

  • single (32-bit floating point)

  • float (32-bit floating point)

  • double (64-bit floating point)

append

Determines if we should add variables to an existing file, if present.

put_data

Flag indicating whether to write data contained in vars. If FALSE, only dimensions and coordinate varibles will be written.

quick_append

Flag indicating whether to validate that data written in an append operation conforms to the original dimensions of the file. If TRUE, these checks will not be performed, increasing write performance.