read.netCDF {netCDF}R Documentation

Read subsets of a netCDF file

Description

Reads a hyperrectangle of values for the specified variables from a file in netCDF format.

Usage

read.netCDF(x, name=NULL, id=NULL, start=NULL, count=NULL, byrow=T, attr=T)

Arguments

x A filename or a netCDF object as returned by open.netCDF
name Variable name(s) to read
id Variable id(s) to read (specify this or name)
start upper left corner of hyperrectangle (or list of these if reading more than one variable)
count dimensions of hyperrectangle (or list of these if reading more than one variable

Details

If a filename is given it will be opened before reading and closed afterwards. If a netCDF object is given it will be reopened if necessary but will not be closed.

Variables can be described by their name or their variable id. If only one variable is being read, or if all variable have the same dimensions, start and count are vectors whose length is the number of dimensions. Otherwise they should be lists of vectors.

NetCDF files store data with the first dimension changing slowest, the opposite to R. The byrow=T transposes the data so that the first dimension changes fastest. This is easier to understand, but presumably takes more time and memory.

Value

A matrix or list of matrices containing the data, with attributes if attr=T

Note

This code uses the deprecated netCDF version 2 compatibility library and should be updated.

Author(s)

Thomas Lumley

References

Unidata NetCDF website http://www.unidata.ucar.edu/packages/netcdf/

See Also

open.netCDF, close.netCDF

Examples