Pymasker is a python package to generate various masks from the Landsat 8 Quality Assessment band and MODIS land products.
The package can be shipped to your computer using pip.
pip install pymasker
Or just install it with the source code.
python setup.py install
This package depends on numpy and GDAL.
An ArcMap python toolbox based on this package could be find here.
For Landsat 8 Quality Accessment band
from pymasker import LandsatMasker
from pymasker import LandsatConfidence
# load the QA band directly
masker = LandsatMasker('LC80170302014272LGN00_BQA.TIF')
# algorithm has high confidence that this condition exists (67-100 percent confidence)
conf = LandsatConfidence.high
# Get mask indicating cloud pixels with high confidence
mask = masker.get_cloud_mask(conf)
# save the result
masker.save_tif(mask, 'result.tif')
For MODIS land products
from pymasker import ModisMasker
from pymasker import ModisQuality
# load the QA band directly
masker = ModisMasker('MOD09GQ.A2015025.h12v04.005.2015027064556.hdf')
# Corrected product produced at ideal quality for all bands.
quality = ModisQuality.high
# Create a MODIS QA masker
mask = masker.get_qa_mask(quality)
# save the result
masker.save_tif(mask, 'result.tif')
pymasker -s landsat -i landsat.tif -o mask.tif -c high -t cirrus
General parameters:
-s, --source SOURCE
source type: landsat, modis
-i, --input INPUT
input image file path
-o, --output OUTPUT
output raster path
Landsat parameters:
-c, --confidence CONFIDENCE
level of confidence that a condition exists in a landsat image: high, medium, low, undefined, none
-t, --target TARGET
target object: cloud, cirrus, water, vegetation, snow
MODIS parameters:
-q, --quality QUALITY
Level of data quality of MODIS land products at each pixel: high, medium, low, low_cloud
The following two articles explains the mechanism behind the tool in detail.
node-qa-masker provides the same masking functionality in NodeJS.
-
0.3.2
- Add
get_fill_mask()
to LandsatMasker (thanks to kbasten)
- Add
-
0.3.1
- Simplify the initialization of ModisMasker
-
0.3.0
- BREAKING CHANGE change most class and function names according to pep8
- add command line tool