0

I saw this script in GEE website for masking clouds of Sentinel 2 imagery:

function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));

  return image.updateMask(mask).divide(10000);
}

However, I see other people changing the second part of the script to:

  var cloudBitMask = Math.pow(2, 10);
  var cirrusBitMask = Math.pow(2, 11); 

or:

  var cloudBitMask = ee.Number(2).pow(10).int()
  var cirrusBitMask = ee.Number(2).pow(11).int()

I do not understand why they change the values 1 to 2. Is it something that has to be changed manually? I thought these bits has to remain as they are in the provided script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.