QAMasker#

class geowombat.radiometry.QAMasker(qa, sensor, mask_items=None, modis_qa_band=1, modis_quality=2, confidence_level='yes')[source]#

Bases: object

A class for masking bit-packed quality flags.

Parameters:
  • qa (DataArray) – The band quality array.

  • sensor (str) –

    The sensor name. Choices are [‘ard’, ‘hls’, ‘l8-pre’, ‘l8-c1’, ‘l-c1’, ‘modis’, ‘s2a’, ‘s2c’].

    Codes:
    ’ard’:

    USGS Landsat Analysis Ready Data <https://www.usgs.gov/land-resources/nli/landsat/us-landsat-analysis-ready-data?qt-science_support_page_related_con=0#qt-science_support_page_related_con>`_

    ’hls’:

    NASA Harmonized Landsat Sentinel

    ’l-c1’:

    Landsat Collection 1 L4-5 and L7

    ’l8-c1’:

    Landsat Collection 1 L8

    ’s2a’:

    Sentinel 2A (surface reflectance)

    ’s2c’:

    Sentinel 2C (top of atmosphere)

  • mask_items (str list) – A list of items to mask.

  • modis_qa_position (Optional[int]) – The MODIS QA band position. Default is 1.

  • modis_quality (Optional[int]) – The MODIS quality level. Default is 2.

  • confidence_level (Optional[str]) – The confidence level. Choices are [‘notdet’, ‘no’, ‘maybe’, ‘yes’].

References

Landsat Collection 1:

https://landsat.usgs.gov/collectionqualityband

Examples

>>> import geowombat as gw
>>> from geowombat.radiometry import QAMasker
>>>
>>> # Get the MODIS cloud mask.
>>> with gw.open('qa.tif') as qa:
>>>     mask = QAMasker(qs, 'modis').to_mask()
>>>
>>> # NASA HLS
>>> with gw.open('qa.tif') as qa:
>>>     mask = QAMasker(qs, 'hls', ['cloud']).to_mask()

Methods

to_mask()

Converts QA bit-packed data to an integer mask.

Methods Documentation

to_mask()[source]#

Converts QA bit-packed data to an integer mask.

Returns:

0: clear, 1: water, 2: shadow, 3: snow or ice, 4: cloud, 5: cirrus cloud, 6: adjacent cloud, 7: saturated, 8: dropped, 9: terrain occluded, 255: fill

Return type:

xarray.DataArray

to_mask()[source]#

Converts QA bit-packed data to an integer mask.

Returns:

0: clear, 1: water, 2: shadow, 3: snow or ice, 4: cloud, 5: cirrus cloud, 6: adjacent cloud, 7: saturated, 8: dropped, 9: terrain occluded, 255: fill

Return type:

xarray.DataArray