0

I am having issues with my script. I can't seem to get the cloud mask to work as apparently the Qa60 band can't be found. ideas?

//1 Mask Clouds
function maskS2clouds(sentColl) {
  var qa = sentColl.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 sentColl.updateMask(mask).divide(10000);
}
//2. Define Sentinel-2 Image Collection
var sentColl = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
                  .filterDate('2019-06-01', '2019-08-31')
                  .filterMetadata ('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10)
                  .filterBounds(AOI)
                  .select(['B2', 'B3', 'B4', 'B8'])
                  .map(maskS2clouds);
                 
print(sentColl);

//4. Compute the median in each band and each pixel. Band names are B2_Median, B3_Median etc.
 var imgMed = sentColl.reduce(ee.Reducer.median());
 //5. Output image. Add it to map.
var VisualizeP = {
bands:['B2_median', 'B3_median', 'B4_median'],
min:15,
max:5001,
gamma:1.30,
};
//Map.addLayer(imgMed,VisualizeP);
Map.centerObject(AOI,10);

//Clip image
var NS_Sent_2019 = imgMed.clip(AOI)
 Map.addLayer(NS_Sent_2019,VisualizeP);
 //6. Export image 
Export.image.toDrive({
  image:imgMed,
  description: 'Y2019',
  scale: 5,
  region: AOI,
  maxPixels:16792443500
})
0

0

Browse other questions tagged or ask your own question.