I'm aware that there are a lot of questions already on this topic, however, I could not find an answer to my problem.

For a project, I need to use a script with a cloud masking procedure written by someone else. I am using Landsat 8 Surface Reflectance Tier 1 Level 2 data, which is subsequently masked using the QA_PIXEL-band of the image collection. According to the documentation, the QA_PIXEL-band stores the 'pixel quality attributes generated from the CFMASK algorithm', which is a well-documented algorithm to mask clouds.

To my knowledge, the CFMASK algorithm classifies every pixel in quality categories which are encoded in bits in this attribute. The meaning of the numbers in this attribute can be decoded using for instance this table from this document:

pixel quality table

Now, if I compare the numbers in the remap() operation below with the table, I can only conclude that they don't match. How can I interpret what is exactly masked with the numbers in the remap() operation below?

var MySubset = ee.FeatureCollection([ee.Feature(ee.Geometry.Polygon(
    [-119.49464510322251,36.787477097017394]]), {sample_id : 1376505}),
      [-120.0301812906031,36.732399470516334]]), {sample_id : 1376091})

var dataset = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")

var cloudfree = dataset.map(function(image) {
    var initial = image.select('SR_B3').toInt16().mask(image.select('QA_PIXEL')
    return initial.copyProperties(initial,ee.List(['system:time_start']));

1 Answer 1


The numbers in your function appear to be for the Level 1 product, not the level 2 (surface reflectance) product.

enter image description here See: https://www.usgs.gov/media/images/landsat-8-quality-assessment-band-attributes-and-possible-values

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.