Main Content

matlab.io.hdfeos.sw.defComp

Namespace: matlab.io.hdfeos.sw

Set grid field compression

Syntax

defComp(swathID,compscheme,compparm)

Description

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

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

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

Fields defined with compression must be written with a single call to sw.writeField.

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

Examples

import matlab.io.hdfeos.*
swfid = sw.open('myfile.hdf','create');
swathID = sw.create(swfid,'MySwath');
sw.defDim(swathID,'Track',4000);
sw.defDim(swathID,'Xtrack',2000);
sw.defDim(swathID,'Bands',3);
sw.defComp(swathID,'rle');
dims = {'Xtrack','Track'};
sw.defDataField(swathID,'Pressure',dims,'float');
sw.defComp(swathID,'deflate',5);
sw.defDataField(swathID,'Opacity',dims,'float');
sw.defComp(swathID,'skphuff');
dims = {'Xtrack','Track','Bands'};
sw.defDataField(swathID,'Spectra',dims,'float');
sw.defComp(swathID,'none');
dims = {'Xtrack','Track'};
sw.defDataField(swathID,'Temperature',dims,'float');
sw.detach(swathID);
sw.close(swfid);

See Also