Routines (alphabetical) > Routines: H > HDF Routines > HDF_GR_SETATTR

# HDF_GR_SETATTR

This function attaches the attribute to the HDF GR object specified by the parameter obj_id. The attribute is defined by its name, data type, number of attribute values, and the attribute values. HDF_GR_SETATTR provides a generic way for users to define metadata. It implements the label = value data abstraction. If an HDF GR interface identifier (gr_id) is specified as the parameter obj_id, a global attribute is created that applies to all objects in the file. If a raster image identifier (ri_id) is specified as the parameter obj_id, an attribute is attached to the specified raster image. Attribute values are passed in the parameter values. The number of attribute values is defined by the parameter count. If more than one value is stored, all values must have the same data type. If an attribute with the given name, data type and number of values exists, it will be overwritten. Currently, the only predefined attribute is the fill value, identified by the attribute name “FillValue”.

## Syntax

Result = HDF_GR_SETATTR(obj_id, attr_name, data_type, count, values)

## Return Value

Returns SUCCEED (0) if successful or FAIL (-1) otherwise.

## Arguments

### obj_id

Raster image identifier (ri_id), returned by HDF_GR_CREATE or HDF_GR_SELECT or HDF GR interface identifier (gr_id), returned by HDF_GR_START.

### attr_name

Name of the attribute (string).

### data_type

Data type of the attribute (integer). Can be any data type supported by the HDF library.

### count

Number of values in the attribute.

### values

The attribute value.

## Keywords

None

## Version History

5.2 | Introduced