authority: folia
slug: qa-pixel
name: Landsat Collection 2 QA Pixel
domain: atmosphere
subdomain: processing
authority_id: folia:qa-pixel
external_ids:
  cf_standard_name: null
canonical_units: categorical
external_validations:
  product:
    id: landsat-c2-l2-qa-pixel
    docs_url: https://www.usgs.gov/landsat-missions/landsat-collection-2-level-2-science-products
  library:
    name: usgs-landsat-qa-bands
    id: landsat-c2-qa-pixel
    docs_url: https://www.usgs.gov/landsat-missions/landsat-collection-2-quality-assessment-bands
  gee:
    op: ee.ImageCollection 'LANDSAT/LC09_L2' QA_PIXEL band
    docs_url: https://developers.google.com/earth-engine/datasets/catalog/landsat
description: |
  Bit-packed per-pixel quality flags shipped as the `QA_PIXEL` band of
  Landsat Collection 2 Level-2 surface-reflectance products (LSDS-1619
  Data Format Control Book). One 16-bit unsigned integer per pixel
  encodes fill, cloud, cloud-shadow, snow, water, and per-class confidence
  fields. Canonical bit layout (Landsat 4-9 Collection 2):

  | bit | meaning |
  |-----|---------|
  | 0 | Fill |
  | 1 | Dilated cloud |
  | 2 | Cirrus (Landsat 8/9 only) |
  | 3 | Cloud |
  | 4 | Cloud shadow |
  | 5 | Snow |
  | 6 | Clear |
  | 7 | Water |
  | 8-9 | Cloud confidence (00=none, 01=low, 10=medium, 11=high) |
  | 10-11 | Cloud shadow confidence |
  | 12-13 | Snow/ice confidence |
  | 14-15 | Cirrus confidence (Landsat 8/9 only) |

  Common usage is a bitwise unpack: `image.select('QA_PIXEL').bitwiseAnd(1 << 3).neq(0)`
  picks the cloud bit. QA_PIXEL is equivalent to (but more granular than)
  the Sentinel-2 SCL — every optical Landsat op consumes it as its primary
  cloud / shadow / water / snow mask.
theme: imagery
example_recipes:
  - title: "Bitwise unpack of cloud bit from QA_PIXEL (GEE)"
    tool: gee
    requires: []
    snippet: |
      var img = ee.Image('LANDSAT/LC09_L2SP_T1/LC09_044034_20240615');
      var qa = img.select('QA_PIXEL');
      var cloud = qa.bitwiseAnd(1 << 3).neq(0);          // bit 3 = cloud
      var shadow = qa.bitwiseAnd(1 << 4).neq(0);         // bit 4 = cloud shadow
      var clearMask = cloud.or(shadow).not();
    docs_url: https://www.usgs.gov/landsat-missions/landsat-collection-2-quality-assessment-bands
consumed_by: []
produced_by: []
demos: []
status: documented
sources:
  - https://www.usgs.gov/landsat-missions/landsat-collection-2-level-2-science-products
  - https://www.usgs.gov/landsat-missions/landsat-collection-2-quality-assessment-bands
  - https://developers.google.com/earth-engine/datasets/catalog/landsat
