I'm trying to isolate ocean cover from OLCI imagery using a bitmask from the quality_flags band. But it's masking all the pixels, and I notice when I mask the ocean and leave the land, the land is very patchy compared to non-masked imagery.
Here's a link: https://code.earthengine.google.com/8b979aedb7f91352ccd792c63af8ca39
Here's the code I'm using:
//Land mask
function maskLand(image) {
// Bit 31 is land/sea cover
var LandBitMask = ee.Number(2).pow(31).int();
// Get the pixel QA band
var qf = image.select('quality_flags');
// The flags should be set to one, indicating water cover.
var mask = qf.bitwiseAnd(LandBitMask).eq(1);
return image.updateMask(mask)
}
//Create image collection for area and date range
var lis_collection = ee.ImageCollection(olci)
.filterBounds(lis)
.filterDate('2018-05-01', '2018-10-01');
//Mask the image collection to water
var lis_mask = lis_collection.map(maskLand);
//Mosaic, clip, and display the area
var lis_area = lis_mask.mosaic();
var lis_area = lis_area.clip(lis);
print(lis_area);
Map.addLayer(lis_area, oa5vis, "Long Island Sound radiance");
Is there a better way to do this?
Perhaps some kind of mask I can run on the clipped mosaic instead of a function to run on the image collection.