Learn R Programming

ncdf.tools (version 0.7.1.295)

modifyNcdfDefAtts: Define a set netCDF attributes at once

Description

Easily define a couple of attributes for a single netCDF variable in one step.

Usage

modifyNcdfDefAtts(file.con, var.id, atts)

Arguments

file.con
a NetCDF object pointing to the respective netCDF file.
var.id
the variable id (integer) or name (string) for which to define attributes.
atts
list: the attributes to define (see details or an example).

Details

The atts attribute should be a list with as many elements as attributes should be added to the variable in the netCDF file. The names of the attributes are taken from the names of the elements of this list and the attribute values are defined by the values of the list elements. The type/class of the attribute (values) is determined automatically.

See Also

att.put.nc

Examples

Run this code
## needs an open connection to a valid netCDF file pointed to by file.con
attributes.define <- list(LongName = 'This is the long name',
                          missingValue = -99999,
                          units = 'm/s')
library(RNetCDF)
file.con   <- create.nc('test.nc')
dim.def.nc(file.con, 'testdim')
var.def.nc(file.con, 'test', 'NC_CHAR', 'testdim')
modifyNcdfDefAtts(file.con, 'test', atts = attributes.define)

## show all attributes
infoNcdfAtts(file.con, 'test')

Run the code above in your browser using DataLab