R: R Interface to NetCDF Datasets

RNetCDF {RNetCDF} | R Documentation

## R Interface to NetCDF Datasets

### Description

This package provides an interface to Unidata's NetCDF library functions (version 4) and furthermore access to Unidata's UDUNITS (version 2) calendar conversions. The routines and the documentation follow the NetCDF and UDUNITS C interface, so the corresponding manuals can be consulted for more detailed information.

NetCDF is an abstraction that supports a view of data as a collection of self-describing, portable objects that can be accessed through a simple interface. Array values may be accessed directly, without knowing details of how the data are stored. Auxiliary information about the data, such as what units are used, may be stored with the data. Generic utilities and application programs can access NetCDF datasets and transform, combine, analyze, or display specified fields of the data.

First versions of the R and C code of this package were based on the `netCDF` package by Thomas Lumley and the `ncdf` package by David Pierce. Milton Woods added some enhancements of the NetCDF library versions 3.6 and 4.x.

### Functions

Help pages are available for the following RNetCDF functions:

Category | Function
Dataset | `close.nc`
| `create.nc`
| `file.inq.nc`
| `open.nc`
| `print.nc`
| `read.nc`
| `sync.nc`
Group | `grp.def.nc`
| `grp.inq.nc`
| `grp.rename.nc`
Attribute | `att.copy.nc`
| `att.delete.nc`
| `att.get.nc`
| `att.inq.nc`
| `att.put.nc`
| `att.rename.nc`
Dimension | `dim.def.nc`
| `dim.inq.nc`
| `dim.rename.nc`
Data type | `type.def.nc`
| `type.inq.nc`
Variable | `var.def.nc`
| `var.get.nc`
| `var.inq.nc`
| `var.par.nc`
| `var.put.nc`
| `var.rename.nc`
Calendar | `utcal.nc`
| `utinit.nc`
| `utinvcal.nc`

### Data Types

The external types supported by all NetCDF datasets are:

`NC_CHAR` | 8-bit characters intended for representing text.
`NC_BYTE` | 8-bit signed integers.
`NC_SHORT` | 16-bit signed integers.
`NC_INT` | 32-bit signed integers.
`NC_FLOAT` | 32-bit IEEE floating-point.
`NC_DOUBLE` | 64-bit IEEE floating-point.

Datasets in NetCDF4 format support additional external types, including:

`NC_UBYTE` | 8-bit unsigned integers.
`NC_USHORT` | 16-bit unsigned integers.
`NC_UINT` | 32-bit unsigned integers.
`NC_INT64` | 64-bit signed integers.
`NC_UINT64` | 64-bit unsigned integers.
`NC_STRING` | variable length character strings.

These types are called “external”, because they correspond to the portable external representation for NetCDF data. When a program reads external NetCDF data into an internal variable, the data is converted, if necessary, into the specified internal type. Similarly, if you write internal data into a NetCDF variable, this may cause it to be converted to a different external type, if the external type for the NetCDF variable differs from the internal type.

In addition to the external types, NetCDF4 supports user-defined types. See `type.def.nc` for more explanation.

### Note

When installing RNetCDF from source code, the netcdf4 library and header files must be installed on the system. Calendar functions will only be enabled in RNetCDF if the udunits2 library and header files are detected during the build process. Parallel file access requires a netcdf4 library built with MPI support along with an MPI interface package installed in R (e.g. pbdMPI or Rmpi).

### Author(s)

Pavel Michna, Milton Woods

### References

https://www.unidata.ucar.edu/software/netcdf/

https://www.unidata.ucar.edu/software/udunits/

[Package RNetCDF version 2.4-2 Index]