var.put.ncv {ncvar} | R Documentation |
Put data and associated metadata of a NetCDF variable.
var.put.ncv(path, var, new=TRUE, define=TRUE, data=TRUE, recursion=0, verbose=FALSE)
path |
Filename of the NetCDF file to be created/opened. |
var |
The variable object (class "var.ncv "), as
returned from var.def.ncv . |
new |
Set to TRUE if a new file should be created,
otherwise an exisiting file will be opened for writing. |
define |
If TRUE , define the data and associated metadata
(NetCDF define mode).
Set to FALSE , if the variables already have been defined. |
data |
If TRUE , write the data to the file (NetCDF data mode).
Set to FALSE , if no data should be written. |
recursion |
For internal use only. |
verbose |
For internal use only. |
This function writes the data and and associated metadata of a
variable to a NetCDF file. Type conversion is done by the NetCDF library
itself. Special treatment is necessary for the R type character
.
When writing values
of type NC_CHAR
, it is mandatory that the first element of
count
contains the value of this dimension's length
(usually max_string_length
), the maximum string length is given
by this value. R arrays of type character
need therefore one
additional dimension when written to a NetCDF dataset.
Values of NA
are supported if the variable's missing value
attribute (missing\_value
or _FillValue
) is set. They are converted to the
corresponding value before written to disk.
Data in a NetCDF file is conceived as being a multi-dimensional array.
The number and length of dimensions is determined when the variable is
created. The start
and count
indices that this routine takes
indicate where the writing starts along each dimension, and the count of
values along each dimension to write.
Note that the order of dimensions is consistent with the R conventions (the first dimension varies fastest), but opposite to the CDL conventions.
NC_BYTE
is always interpreted as signed.
Juerg Schmidli
http://www.unidata.ucar.edu/packages/netcdf/
## Copy data from one file to another foo.ncv() temp <- var.get.ncv(paste(tempdir(),"/foo.nc",sep=""), "temperature", mode="cf") var.put.ncv(paste(tempdir(),"/foo2.nc",sep=""), temp)