I would like to understand what the logic of this code is (I know that with this code it is possible to mask the pixels classified as cloud and cloud shadow of Landsat 8 images).
I'm still having some difficulties understanding bitwise operators.
function maskL8sr(image) {
// Bits 3 and 5 are cloud shadow and cloud, respectively.
var cloudShadowBitMask = 1 << 3;
var cloudsBitMask = 1 << 5;
// Get the pixel QA band.
var qa = image.select('pixel_qa');
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0));
// Return the masked image.
return image.updateMask(mask);
}