Main Content

matlab.io.hdfeos.gd.defComp

Namespace: matlab.io.hdfeos.gd

Set grid field compression

Syntax

defComp(gridID,compscheme,compparm)

Description

defComp(gridID,compscheme,compparm) sets the HDF field compression for subsequent field definitions. The compression scheme does not apply to one-dimensional fields. compscheme can be one of the following values.

'rle'Run-length encoding
'skphuff'Skipping Huffman
'deflate'Gzip deflate
'none'No compression

When the compression scheme is 'deflate', compparm is the deflate compression level, an integer between 0 and 9. compparm can be omitted for the other compression schemes.

If a field is defined with compression, it must be written with a single call to gd.writeField. If this is not possible, you should consider using tiling.

This function corresponds to the GDdefcomp function in the HDF-EOS library C API.

Examples

Create a grid with a polar stereographic Pressure field using run-length encoding, and then an Opacity field with deflate compression.

import matlab.io.hdfeos.*
gfid = gd.open('myfile.hdf','create');
gridID = gd.create(gfid,'PolarGrid',100,100,[],[]);
projparm = zeros(1,13);
projparm(6) = 90000000;
gd.defProj(gridID,'ps',[],'WGS 84',projparm);
dims = { 'XDim', 'YDim' };
gd.defComp(gridID,'rle');
gd.defField(gridID,'Pressure',dims,'float');
gd.defComp(gridID,'deflate',5);
gd.defField(gridID,'Opacity',dims,'float');
gd.detach(gridID);
gd.close(gfid);