Skip to content
Prev 247175 / 398503 Next

RNetCDF: retrieving variable names and units

There are a number of functions in the package to inquire about the
file contents. See library(help = RNetCDF).

For example:

library(RNetCDF)

nc <- open.nc("file.nc")

var.inq.nc(nc, 0)
$id
[1] 0

$name
[1] "longitude_U"

$type
[1] "NC_DOUBLE"

$ndims
[1] 1

$dimids
[1] 1

$natts
[1] 0

You can then read from the file with something like this:

obj0 <- var.inq.nc(nc, 0)
dat <- var.get.nc(nc, obj0$name, start = ...)

Going with ncdf or ncdf4 package is probably better ( I just happen to
be more familiar with RNetCDF.)

Cheers, Mike.
On Thu, Jan 13, 2011 at 9:00 AM, Jannis <bt_jannis at yahoo.de> wrote: