Bilko logo
Bilko Mini-lessons

Mini-Lesson 7: Using flag code images

Lesson Aims:

To introduce you to how to use the bit-wise operators of formula documents that allow you to utilise the "flag" coding information that is provided with some images.


By the end of this mini-lesson you will have explored how bit-wise operators allow you to utilise the "flag" code images that come with data such as MERIS and AVHRR and indicate features such as coastline, cloud, sun glint, etc.

Download the lesson:

If you have already registered as a Bilko user you can download this lesson by entering your e-mail address in the box below. If you are new to Bilko please register first, using the link on the top menu bar.

spacerspacer spacer


Content Overview

Much imagery is now supplied with flag codings that give you information about each pixel. Flag-codings are a special type of metadata. They are classification or quality flags stored as per-pixel bit fields in "flag bands". A product can have multiple flag bands and therefore also multiple flag-codings.

Flag-codings can play an important role in image interpretation, e.g. by allowing poor data to be excluded from analysis using bit-mask overlays derived from the flag values in a flag band. Bit-wise operators are needed to utilise these flag codings.


Colour composite of the MERIS (Medium Resolution Imaging Spectrometer) of the Alps, Italy and the central Mediterranean (bands 7, 5 and 2) used in this mini-lesson.


Examples are the AVHRR (Advanced Very High Resolution Radiometer) sensor of the United States' National Oceanographic and Atmospheric Administration (NOAA), and the MERIS (Medium Resolution Imaging Spectrometer) and AATSR (Advanced Along Track Scanning Radiometer) sensors of the European Space Agency's ENVISAT satellite. The flag attributes indicate such things as where there is land, water, cloud, coastline, sun glint, invalid data, etc. on the image.

Sample images:

A selection of images from this mini lesson are shown below.

Bilko file-structure window showing the hierarchically structured N1 format file for the MERIS image of the Mediterranean used in this mini-lesson. The file contains Metadata, Flag codings, Tie point grids, and the 15 (radiance) bands themselves. The contents of the flag codings text file are shown as an inset. The flag codings image is listed after band 15 as I1_flags.


Table of flag codings for MERIS Level 1B images.

The formula document above uses flag codings image to mask (set to zero) areas that (i) have glint risk, (ii) are suspect, (iii) are land, (iv) are bright (i.e. have thick cloud or are causing sensor saturation for some other reason), or (v) are invalid. "!" = NOT operator and "&" = bit-wise AND operator.


Automatic linear stretch of the flag codings image with most of the sea set to 0, most of the land set to 16, and the coastline set to 80. The patch of cloud over the land in the north-east of the image is mainly set to 48 (bright + land).

One radiance band of the MERIS image with unwanted pixels masked out using the formula document. The coastline has also been delineated as a bright line.

backarrow Previous: Mini-lesson 6 Last update: 31 January 2018      Contact          Up         Site Policy         Next: Mini-lesson 8 Next