[R] RNetCDF: retrieving variable names and units

Michael Sumner mdsumner at gmail.com
Wed Jan 12 23:26:16 CET 2011

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

For example:


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

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

[1] "longitude_U"


[1] 1

[1] 1

[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:
> Dear List,
> does anybody has experience with the RNetCDF package? I manage to open a connection and copy data from a ncdf file but would need a way to automatically retrieve variable names (ideally all of them from one file) and units from the file.
> Any ideas?
> Jannis
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com

More information about the R-help mailing list