Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

grp.def.nc

Define a NetCDF Group


Description

Define a NetCDF Group.

Usage

grp.def.nc(ncid, grpname)

Arguments

ncid

Object of class "NetCDF" which points to the NetCDF dataset (as returned from open.nc) or parent group (as returned by this function).

grpname

Group name. Must begin with an alphabetic character, followed by zero or more alphanumeric characters including the underscore ("_"). Case is significant.

Details

This function may only be used with files in netcdf4 format. It creates a new NetCDF group, which may be used as a container for other NetCDF objects, including groups, dimensions, variables and attributes.

Most NetCDF object types, including groups, variables and "global" attributes, are visible only in the group where they are defined. However, dimensions are visible in their groups and all child groups.

Value

Object of class "NetCDF" which points to the NetCDF group, returned invisibly.

Author(s)

Pavel Michna, Milton Woods

References

Examples

##  Create a new NetCDF4 dataset
file1 <- tempfile("grp.def_", fileext=".nc")
nc <- create.nc(file1, format="netcdf4")

## Define dimensions, variables and attributes in the root group
dim.def.nc(nc, "station", 5)
var.def.nc(nc, "station", "NC_CHAR", c("station"))
att.put.nc(nc, "NC_GLOBAL", "Description", "NC_CHAR", "Site-based measurements") 

## Define a group
grp <- grp.def.nc(nc, "time_series")

## Define dimensions and variables in the new group
dim.def.nc(grp, "time", unlim=TRUE)
var.def.nc(grp, "time", "NC_INT", "time")
var.def.nc(grp, "temperature", "NC_DOUBLE", c("station","time"))
att.put.nc(nc, "NC_GLOBAL", "Description", "NC_CHAR", "Time-series at sites")

close.nc(nc)
unlink(file1)

RNetCDF

Interface to 'NetCDF' Datasets

v2.4-2
GPL (>= 2) | file LICENSE
Authors
Pavel Michna [aut], Milton Woods [aut, cre]
Initial release
2020-09-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.