I want to mask pixels based on the quality band information for image collection Landsat 5. This is my code but the image-collection is empty afterward.

Can you 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))
// 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')
  • As a side note, updateMask is not capitalized like you spelled it in your code.
    – M. Nicolas
    Nov 28, 2023 at 23:13

1 Answer 1


The collection is not empty; rather, it contains images which are entirely masked.

var mask1 = img.select('pixel_qa').eq(66).eq(130)

This line

  • takes the pixel_qa band,
  • transforms it into an image which is 1 wherever the value was 66 and 0 otherwise,
  • and then compares that with 130.

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:

var collection1992_noclouds = collection1992.map(function(img) {
  var pixel_qa = img.select('pixel_qa');
  return pixel_qa.eq(66).max(pixel_qa.eq(130));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.