I don not understand why are there holes in the resulting map of median reflectance values from S2 imagery on GEE and how do I fix it?

Also, why are all the clouds not getting masked?

//Function for masking clouds // http://xzsunbest.tk/2018/07/05/MaskingOutCloudInSentinel2WithGEE/ // Bits 10 and 11 are clouds and cirrus, respectively.

var cloudBitMask = ee.Number(2).pow(10).int();
var cirrusBitMask = ee.Number(2).pow(11).int();
// Simple cloudMask function for Sentinel-2 based on QA band 
function cloudmask(image) {
var qa = image.select('QA60');
// Both flags should be set to zero, indicating clear conditions.
 var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
       return image.updateMask(mask);

var filtered =  sentinel2.filterBounds(asset).filterDate('2015-01-01','2015-12-31'); //asset is Papua and West Papua i.e Indonesian side of PNG
print('Filtered (by date and ROI) Image Count: ', filtered.size()); //247 

// apply the function on the image collection
var clipped = filtered.map(cloudmask);
print('Filtered and Masked Image Count: ', clipped.size());//247

// Make a composite image
var medianComp = clipped.median();
Map.addLayer(medianComp, {bands:['B4','B3','B2'], min: 0, max: 3500}, 'true color median composite', 0);
  • I tried filtering images in the collection by the cloudy pixel percentage and a lot of the worst images were removed, but even then there is still a great deal of haze. I wonder how effective the cloud masks are with fog. Given the humidity on PNG that could be part of the problem. See the code below for my approach (mostly inspired by @rodrigo-e-principe) code.earthengine.google.com/900484fc1311a67696dd801b9b49b75d – JepsonNomad Feb 21 at 1:56

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.