I am new to earth engine and I am trying to apply a radiometric saturation mask in a image collection based on ''radsat_qa'' in earth engine data catalog for landsat reflectance tier 1.

I am trying to apply that radiometric mask in that collection :

var Landsat_5 = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
               .filterDate('1984-03-01', '2012-05-01')

2 Answers 2


Using radsat_qa require some bit manipulation. I usually copy and paste my little bitwiseExtract() function for these things. This should give you an idea how you can use it:

function cloudMaskL457(image) {
  // Look for the bitmasks in
  // https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LT05_C01_T1_SR
  var pixelQA = image.select('pixel_qa')
  var clear = bitwiseExtract(pixelQA, 1) // 1 if clear
  var water = bitwiseExtract(pixelQA, 2) // 1 if water

  var radsatQA = image.select('radsat_qa')
  var band5Saturated = bitwiseExtract(radsatQA, 5) // 0 if band 5 is not saturated
  var anySaturated = bitwiseExtract(radsatQA, 1, 7) // 0 if no bands are saturated

  var mask = clear
  return image.updateMask(mask)

function bitwiseExtract(value, fromBit, toBit) {
  if (toBit === undefined)
    toBit = fromBit
  var maskSize = ee.Number(1).add(toBit).subtract(fromBit)
  var mask = ee.Number(1).leftShift(maskSize).subtract(1)
  return value.rightShift(fromBit).bitwiseAnd(mask)



QA_RADSAT (known as 'radsat_qa' in older LANDSAT versions) is kind of a meta-band that determines whether any of the other bands has been saturated. In Landsat 8, it has 11 bits. If you check out the band properties here, the bits are organized in a straightforward way:

Bit 0: Band 1 data saturated

Bit 1: Band 2 data saturated

Bit 2: Band 3 data saturated

What does it mean for a band to be saturated? It means that the sensor read an extremely high value that exceeds the maximum measurable signal. Features likely to cause saturation include clouds, snow/ice, barren soil, and white sand.

Consequently, the purpose of the QA_RADSAT band is that it can tell us which pixels in our image are saturated, so we can remove them. We remove them by making a bit mask, composed of 1s and 0s. Pixels with a mask value of 1 are pixels we want to keep, 0s are pixels we want to ignore.

Maybe we want to ignore near infrared saturation (band 5), but are okay with other saturation. Then for example, pixels with QA_RADSAT values of '00000010000' or '00000111100' should have a mask value of 0, but '00000001111' or '11111101111' should have a mask value of 1.

We can select all pixels with near-infrared saturation by performing a bitwise AND with '10000', like so:

nirSelect = image.select('QA_RADSAT').bitwiseAnd(parseInt('10000', 2))

('10000' is equivalent to 1 << 5) Because we want the pixels WITHOUT near-infrared saturation, we select the pixels that return 0 from this:

nirMask = image.select('QA_RADSAT').bitwiseAnd(parseInt('10000', 2)).eq(0)

When applied with updateMask(), this will remove all pixels with near-infrared saturation.

It's worth noting that oftentimes you don't want any channels saturated at all, such as for NDVI calculations. In that case, you can simply do:

saturationMask = image.select('QA_RADSAT').eq(0);

To make a mask removing pixels with any saturated bands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.