I want to mask pixels based on the quality band information for image collection Landsat 5. this is a code but the image-collection is empty afterward. I would be thankful if anyone could help me.
var startDate = '1992-01-01'
var endDate = '1993-01-01'
var cloudCover = 30
var collection1992 = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
.filter(ee.Filter.eq('WRS_PATH', 170))
.filter(ee.Filter.eq('WRS_ROW', 32))
.filterDate(startDate,endDate)
.filterMetadata('CLOUD_COVER','less_than',cloudCover)
.sort('system:time_start')
// cloud mask 66,130
var collection1992_noclouds = collection1992.map(function(img) {
var mask1 = img.select('pixel_qa').eq(66).eq(130)
return img.UpdateMask(mask1)
})
Map.addLayer(collection1992_noclouds, {}, 'collection1992_noclouds')
Best Answer
The collection is not empty; rather, it contains images which are entirely masked.
This line
pixel_qa
band,So the mask is always zero the way you have constructed it.
Did you mean that you want to select values of 66 or 130? Then you need to compare against both and combine them. Here's one way to do that: