HDF5 Attribute Interface {rhdf5} | R Documentation

## HDF5 Attribute Interface

### Description

These functions create and manipulate attributes and information about attributes.

### Usage

    H5Acreate       (h5obj, name, dtype_id, h5space)
    H5Aclose        (h5attribute)
    H5Adelete       (h5obj, name)
    H5Aexists       (h5obj, name)
    H5Aget_name     (h5attribute)
    H5Aget_space    (h5attribute)
    H5Aget_type     (h5attribute)
    H5Aopen         (h5obj, name)
    H5Aopen_by_idx  (h5obj, n, objname = ".", index_type = h5default("H5_INDEX"),
                     order = h5default("H5_ITER"))
    H5Aopen_by_name (h5obj, objname = ".", name)
    H5Aread         (h5attribute, buf = NULL)
    H5Awrite        (h5attribute, buf)

### Arguments

`h5obj` | An object of class `H5IdComponent` representing a H5 object identifier (file, group, or dataset). See `H5Fcreate`, `H5Fopen`, `H5Gcreate`, `H5Gopen`, `H5Dcreate`, or `H5Dopen` to create an object of this kind.
`name` | The name of the attribute (character).
`dtype_id` | A character name of a datatype. See `h5const("H5T")` for possible datatypes. Can also be an integer representing an HDF5 datatype. Only simple datatypes are allowed for atttributes.
`h5space` | An object of class `H5IdComponent` representing a H5 dataspace. See `H5Dget_space`, `H5Screate_simple`, `H5Screate` to create an object of this kind.
`h5attribute` | An object of class `H5IdComponent` represnting a H5 attribute as created by `H5Acreate` or `H5Aopen`
`n` | Opens attribute number n in the given order and index. The first attribute is opened with n=0.
`objname` | The name of the object the attribute belongs to.
`index_type` | See `h5const("H5_INDEX")` for possible arguments.
`order` | See `h5const("H5_ITER")` for possible arguments.
`buf` | Reading and writing buffer containing the data to written/read. When using the buffer for reading, the buffer size has to fit the size of the memory space `h5spaceMem`. No extra memory will be allocated for the data. A pointer to the same data is returned.

### Details

Interface to the HDF5 C-library libhdf5. See https://portal.hdfgroup.org/display/HDF5/Attributes for further details.

### Value

`H5Acreate`, `H5Aopen`, `H5Aopen_by_name`, `H5Aopen_by_idx` return an object of class `H5IdComponent` representing a H5 attribute identifier.

`H5Aget_space` returns an object of class `H5IdComponent` representing a H5 dataspace identifier.

`H5Aread` returns an array with the read data.

The other functions return the standard return value from their respective C-functions.

### Author(s)

Bernd Fischer

### References

https://portal.hdfgroup.org/display/HDF5

### See Also

rhdf5

### Examples

    # create a file and write something
    h5createFile("ex_H5A.h5")
    h5write(1:15, "ex_H5A.h5","A")

    # write an attribute 'unit' to 'A'
    fid <- H5Fopen("ex_H5A.h5")
    did <- H5Dopen(fid, "A")
    sid <- H5Screate_simple(c(1,1))
    tid <- H5Tcopy("H5T_C_S1")

    H5Tset_size(tid, 10L)
    aid <- H5Acreate(did, "unit", tid, sid)
    aid
    H5Awrite(aid, "liter")
    H5Aclose(aid)
    H5Sclose(sid)
    H5Aexists(did, "unit")
    H5Dclose(did)
    H5Fclose(fid)
    h5dump("ex_H5A.h5")

[Package rhdf5 version 2.36.0 Index]