The bitmap is an array of binary values. Its purpose is to indicate the presence or absence of data at each of the grid points. A value of '0' means data is missing and a '1' means data is present.
Note: The bitmap section is optional. If it is not present, it means every grid point has an associated value.

In order to conserve space, the bitmap is used to efficiently indicate those data points that actually appear in the Data Section.



Encoded data



In the example shown above, we have 12 grid points of which 3 have actual 'real' values which are {2.5, 4.6, 9.1}.

The bitmap size is the number of points in the grid (ecCodes key "numberOfPoints").

When encoding, you can use the key "missingValue" to tell the library where data is missing.

By default this is 9999 but it can be changed by the user e.g. a value out of the range of normal data.

You must also set the key "bitmapPresent" to 1.

When the library encounters a value equal to the missing value in the data array, it will set the bitmap entry to 0 for that grid point. For an example see grib_set_bitmap

When decoding, you can directly query the bitmap to discover missing data values. For an example see grib_iterator_bitmap

The value of the "missingValue" key used to encode the data is not itself encoded in the GRIB.