HDF5 Dataspace Interface {rhdf5} | R Documentation

## HDF5 Dataspace Interface

### Description

These functions create and manipulate the dataspace in which to store the elements of a dataset.

### Usage

    H5Screate                 (type = h5default("H5S"), native = FALSE)
    H5Screate_simple          (dims, maxdims, native = FALSE)
    H5Scopy                   (h5space)
    H5Sclose                  (h5space)
    H5Sis_simple              (h5space)
    H5Sget_simple_extent_dims (h5space)
    H5Sset_extent_simple      (h5space, dims, maxdims)
    H5Sselect_hyperslab       (h5space, op = h5default("H5S_SELECT"),
                               start = NULL, stride = NULL, count = NULL,
                               block = NULL)
    H5Sselect_index           (h5space, index)
    H5Sunlimited              ()

### Arguments

`type` | See `h5const("H5S")` for possible types.
`dims` | Dimension of the dataspace. This argument is similar to the dim attribute of an array. When viewing the HDF5 dataset with an C-program (e.g. HDFView), the dimensions appear in inverted order, because the fastest changing dimension in R is the first one, and in C its the last one.
`maxdims` | Maximum extension of the dimension of the dataset in the file. If not provided, it is set to dims.
`native` | An object of class `logical`. If TRUE, array-like objects are treated as stored in HDF5 row-major rather than R column-major orientation. Using `native = TRUE` increases HDF5 file portability between programming languages. A file written with `native = TRUE` should also be read with `native = TRUE`

.

`h5space` | An object of class `H5IdComponent` representing a H5 dataspace identifier. See `H5Dget_space`, `H5Screate_simple`, `H5Screate` to create an object of this kind.
`index` | A list of integer indices. The length of the list corresponds to the number of dimensions of the HDF5 array.
`op` | See h5const("H5S_SELECT") for possible arguments.
`start` | The start coordinate of a hyperslab (similar to subsetting in R). Counting is R-style 1-based.
`stride` | The stride of the hypercube. Read the introduction http://ftp.hdfgroup.org/HDF5/Tutor/phypecont.html before using this argument. R behaves like Fortran in this example.
`count` | The number of blocks to be written.
`block` | The block size of the hyperslab. Read the introduction http://ftp.hdfgroup.org/HDF5/Tutor/phypecont.html before using this argument. R behaves like Fortran in this example.

### Details

Interface to the HDF5 C-library libhdf5. See http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html for further details.

As an introduction to use hyperslabs see these tutorials: See these introductions to hyperslabs: http://www.hdfgroup.org/HDF5/Tutor/selectsimple.html, http://www.hdfgroup.org/HDF5/Tutor/select.html and http://ftp.hdfgroup.org/HDF5/Tutor/phypecont.html. Please note that in R the first dimension is the fastest changing dimension. When viewing the HDF5 datasets with any C-program (e.g. HDFView), the order of dimensions is inverted. In the R interface counting starts with 1, whereas in the C-programs (e.g. HDFView) counting starts with 0.

`H5Sselect_index` is not part of the standard HDF5 C interface. It performes an iterative call to H5select_points by iterating through the given index positions. This function avoids a for loop in R. If a list element is NULL, all elements of the respective dimension are considered.

### Value

`H5Screate`, `H5Screate_simple`, and `H5Scopy` return an object of class `H5IdComponent` representing a dataspace.

`H5Sis_simple` returns a boolean.

`H5Sget_simple_extent_dims` returns an integer vector.

`H5Sunlimited` is a simple macro to return the constant `H5S_UNLIMITED` that can be provided to the `maxdims` arguments of `H5Screate_simple` to create and extensible dataspace.

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

### Author(s)

Bernd Fischer

### References

http://www.hdfgroup.org/HDF5

### See Also

rhdf5

### Examples

    sid <- H5Screate_simple(c(10,5,3))
    sid
    H5Sis_simple(sid)
    H5Sget_simple_extent_dims(sid)

    # select a subarray (called hyperslab in the hdf5 community).
    # The next h5write can use this to write a subarray
    H5Sselect_index(sid, list(1:3,2:4,2))

    # always close dataspaces after usage to free recources
    H5Sclose(sid)
    sid

[Package rhdf5 version 2.24.0 Index]