I want to use the LANDSAT/LE07/C01/T1_TOA collection in google earth engine and I am struggling to understand how the bits work in order to mask out areas with clouds and shadows. I managed to write the following, but I am not very confident and do not know how to mask out shadows.
var dataset = ee.ImageCollection('LANDSAT/LE07/C01/T1_TOA')
.filterBounds(geometry)
.map(function(image){return image.clip(geometry)})
.filter(ee.Filter.calendarRange(6,8,'month'))
.filterDate('1999-05-01','2017-09-30');
var qas = function(image) {
var qa = image.select('BQA');
var mask = qa.eq(672);
return image.updateMask(mask).copyProperties(image);
}
var merged = dataset.map(qas);
var addNDVI = function(image) {
var ndvi = image.normalizedDifference(['B4', 'B3']).rename('NDVI');
return image.addBands(ndvi);
};
var ndvi = merged.map(addNDVI);
How to properly do quality masking with bits?