Landsat 8 QA band CLI tool and python lib
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
docs move img to docs May 8, 2017


Build Status

Landsat 8 QA band CLI tool and python module


$ pip install rio-l8qa

Python Usage

The l8qa module provides both qa (for Landsat Collection 1 data) and qa_pre (for pre-Collection landsat data). Both provide a number of functions to extract integer data from the respective QA band formats.

  • cirrus_confidence
  • cloud
  • cloud_confidence
  • cloud_shadow_confidence
  • fill_qa
  • lookup
  • radiometric_qa
  • snow_ice_confidence
  • terrain_qa

And some additional utilty functions to calculate stats or write cloud masks.

  • summary_stats
  • write_cloud_mask


from import cloud_confidence
import rasterio

qatif = "LC08_L1TP_005004_20170410_20170414_01_T1_BQA.TIF"

with as src:
    yesclouds = cloud_confidence( == 3  # high confidence

Command Line Usage

The command line interface currently works only with new Landsat collections format. See docs/ for details.

Summary statistics for each of the QA metrics

$ rio l8qa LC08_L1TP_005004_20170410_20170414_01_T1_BQA.TIF \
  "cloudConf": {
    "maybe": 0.000119,
    "yes": 5e-06,
    "no": 0.486637,
    "notDetermined": 0.513239

To generate output tifs for each QA metric to a directory

$ rio l8qa LC08_L1TP_005004_20170410_20170414_01_T1_BQA.TIF \
    --outdir /tmp
$ ls /tmp

If you need a uint8 0-255 cloud mask, suitable for use as an alpha band in an RGBA geotif, there is a shortcut

$ rio l8qa LC08_L1TP_005004_20170410_20170414_01_T1_BQA.TIF \
    --cloudmask /tmp/justclouds.tif