Skip to contents

Get Zarr Attribute

Usage

get_att(z, var, att)

# S3 method for character
get_att(z, var, att)

# S3 method for NetCDF
get_att(z, var, att)

# S3 method for ZarrGroup
get_att(z, var, att)

# S3 method for `NULL`
get_att(z, var, att)

Arguments

z

an open ZarrGroup as returned by open_nz

var

integer or character zero-based index id of variable of interest or name of variable of interest. -1 or "global" for global attributes

att

integer or character zero-based index id of attribute of interest or name of attribute of interest.

Value

vector containing requested attribute att.get.nc

Examples


z <- open_nz(z_demo())

get_att(z, -1, 2)
#> [1] "CF-1.0"

get_att(z, "global", "Conventions")
#> [1] "CF-1.0"

get_att(z, 0, 3)
#> [1] "Latitude"

get_att(z, "latitude", "long_name")
#> [1] "Latitude"

# equivalent data in NetCDF
if(requireNamespace("RNetCDF", quietly = TRUE)) {
  nc <- z_demo(format = "netcdf")

  (get_att(nc, 0, 0))

  (get_att(nc, "global", 1))
}
#> [1] "CF-1.0"