Routines (alphabetical) > Routines: H > HDF-EOS Routines > EOS_SW_DEFCOMP

# EOS_SW_DEFCOMP

This function sets the HDF field compression for subsequent swath field definitions. The compression does not apply to one-dimensional fields. The compression schemes currently supported are: run length encoding (1), skipping Huffman (3), deflate (gzip) (4) and no compression (0, the default). Compressed fields are written using the standard EOS_SW_WRITEFIELD function, however, the entire field must be written in a single call. Any portion of a compressed field can then be accessed with the EOS_SW_READFIELD function. Compression takes precedence over merging so that multi-dimensional fields that are compressed are not merged. The user should refer to the HDF Reference Manual for a fuller explanation of the compression schemes and parameters.

## Examples

Suppose we wish to compress the Pressure using run length encoding, the Opacity field using deflate compression, the Spectra field with skipping Huffman compression, and use no compression for the Temperature field:

status = EOS_SW_DEFCOMP(swathID, 1)

status = EOS_SW_DEFDATAFIELD(swathID, "Pressure", $

"Track,Xtrack", 5)

compparm[0] = 5

status = EOS_SW_DEFCOMP(swathID, 4, compparm)

status = EOS_SW_DEFDATAFIELD(swathID, "Opacity", $

"Track,Xtrack", 5)

status = EOS_SW_DEFCOMP(swathID, 3)

status = EOS_SW_DEFDATAFIELD(swathID, "Spectra", $

"Bands,Track,Xtrack", 5)

status = EOS_SW_DEFCOMP(swathID, 0)

status = EOS_SW_DEFDATAFIELD(swathID, $

"Temperature", "Track,Xtrack", 5, /MERGE)

Note that the MERGE keyword will be ignored in the Temperature field definition.

## Syntax

Result = EOS_SW_DEFCOMP( swathID, compcode,[, compparm] )

## Return Value

Returns SUCCEED(0) if successful and FAIL(–1) otherwise.

## Arguments

### swathID

Swath id (long) returned by EOS_SW_CREATE or EOS_SW_ATTACH.

### compcode

HDF compression code (long). Allowable values are:

- 0 = None
- 1 = Run Length Encoding (RLE)
- 3 = Skipping Huffman
- 4 = Deflate (gzip)

### compparm

Deflate compression (compcode 4) requires a single integer compression parameter in the range of one to nine with higher values corresponding to greater compression.

## Keywords

None

## Version History

5.2 | Introduced