0

I am trying to mask clouds in Landsat 8 surface reflectance imagery but I am getting a white output (Left image below) - the expected imagery is on the right. enter image description here

Below are the lines of code.

var image = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
   .filterBounds(CCmaine);

function maskL8sr(image) {
  var cloudShadowBitMask = (1 << 4);
  var cloudsBitMask = (1 << 3);

  var qa = image.select('QA_PIXEL');

  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
             .and(qa.bitwiseAnd(cloudsBitMask).eq(0));

  return image.updateMask(mask).divide(10000)
              .select("SR_B[0-9]*")
              .copyProperties(image, ["system:time_start"]);
}

var sum20 = ee.Filter.date('2020-06-01','2020-09-30');
var sum19 = ee.Filter.date('2019-06-01','2019-09-30'); //Note the date adjustment

var SumFilter = ee.Filter.or(sum20, sum19);
var allsum = image.filter(SumFilter);

var composite = allsum
              .map(maskL8sr)
              .median()
              .clip(CCmaine);

Map.addLayer(composite, {bands: ['SR_B4','SR_B3','SR_B2'],min:0, max:0.3},'Cumberland Color Image', 0);

Looking forward to your help!

1 Answer 1

0

Landsat collection 2 images aren't simply scaled by 0.00001. The optical bands are scaled by 0.0000275 and have an offset of -0.2 (the thermal bands are different). This is demonstrated in the code editor examples (Examples > Cloud Masking > Landsat8 Surface Reflectance). In your code, it'd be:

return image.updateMask(mask).multiply(0.0000275).add(-0.2)
1
  • Hi Noel! Thank you soooo much. That worked just fine, Commented Jul 2 at 9:18

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.