Using the QA_PIXEL band in Landsat 8 to mask out clouds, cloud shadow, and land often masks out large areas of water. The QA_PIXEL band identifies these water areas as land and cloud shadow, when this is clearly not correct. An example of this is present in imagery generated by the following script, centered on Fishers Island, NY: https://code.earthengine.google.com/313daa73b1c41ea42342157a8911e5bd
The code used to generate the landmask:
var landtester = function(image){
var landbit = 1 << 7 //Water cover is bit 7
var qaband = image.select('QA_PIXEL');
var landmask = qaband.bitwiseAnd(landbit).gt(0);
return image.updateMask(landmask);
};
var lsimg = ls8.filterBounds(roi)
.filter(ee.Filter.calendarRange(7,9,'month'))
.filter(ee.Filter.calendarRange(2013, 2013, 'year'))
//.filter(ee.Filter.eq('WRS_ROW',22))
.filter(ee.Filter.lt('CLOUD_COVER',50)).first().clip(roi);
var lsimg_lt = landtester(lsimg); Map.addLayer(lsimg_lt, "", "Landmask");
The code calls the proper bit and applies it as a mask. The issue is with the QA_PIXEL data: the incorrectly-masked water areas have a value of 23888, indicating land and high-confidence cloud shadow. There are no clouds nearby that could be casting shadow and the area is clearly water.
This effect usually occurs along the northwest edges of islands and capes. How do I mask land and cloud shadow while avoiding this apparent data quality issue?