Landsat 8 Band Quality Assessment Band

//VERSION=3

function setup() {
  return {
    input: ["B02", "B03", "B04", "BQA"],
    output: { bands: 3, sampleType: "UINT8" },
  };
}

function evaluatePixel(sample) {
  // define the decoder function

  var bqa = decodeL8C2Qa(sample.BQA);

  // defining the colormap

  if (bqa.water == 1) {
    return [0, 0, 204];
  } else if (bqa.snow == 1) {
    return [255, 0, 255];
  } else if (bqa.cloud == 1) {
    return [225, 225, 225];
  } else if (bqa.dilatedCloud == 1) {
    return [175, 175, 175];
  } else if (bqa.cloudShadow == 1) {
    return [153, 102, 51];
  } else if (bqa.cirrus == 1) {
    return [102, 255, 255];
  } else if (bqa.fill == 1) {
    return [255, 0, 0];
  } else if (bqa.clear == 1) {
    return [1000 * sample.B04, 1000 * sample.B03, 1000 * sample.B02];
  } else {
    return [0, 0, 0];
  }
}

Evaluate and visualize

Description

This script uses the decodeL8C2Qa function to decode the BQA band from Landsat 8/9 Collection 2. This is then split into 7 classes:

  • Clear Pixels - returns the True Color image.
  • Water - Dark Blue
  • Snow - Pink
  • Cloud - White
  • Dilated Clouds - Gray
  • Cloud Shadow - Brown
  • Cirrus - Cyan

Description of representative images

BQA class map of Bern. Acquired on 2022-09-01, processed by Sentinel Hub.

L8 BQA

References