Page tree

The license could not be verified: License Certificate has expired!

How do you define a fill value for a dataset?

The fill value is a property list which is specified when creating a dataset. To create a dataset with a fill value, an instance of a dataset creation property list must be modified to define the fill value (see H5Pset_fill_value) and then passed in to the dataset creation call ( H5D_CREATE). Because it is a dataset creation property list, the fill value for a dataset cannot be modified once the dataset has been created.

For example (in C):

  • Create an instance of a dataset creation property list:
     dcpl = H5Pcreate(H5P_DATASET_CREATE);
  • Modify the property list to define a fill value with a value of 99:
     int fillvalue = 99; 
     status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue);  
  • Create the dataset with the modified property list:
     dataset = H5Dcreate(file, DATASETNAME, H5T_STD_I32BE, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);

In HDF4 and other applications, the fill value is specified by creating a special attribute. This has caused confusion for some users who expect the attribute to also work in HDF5, but it does not.

For HDF5 applications that create datasets with fill values, we suggest that the data producer sets the dataset creation property with H5Pset_fill_value and also defines the fill value with a fill value attribute (e.g. _FillValue) for the given dataset.