This is a NodeJS port of pymasker. It provides a convenient way to produce masks from the Quality Assessment band of Landsat 8 OLI images, as well as MODIS land products.
npm install qa-masker
LandsatMasker class provides the functionality to load and generate masks from the Quality Assessment band of Landsat 8 OLI image.
var qm = ;var Masker = qmLandsatMasker;var Confidence = qmLandsatConfidence;// read the band file to initializevar masker = 'LC80170302016198LGN00_BQA.TIF';// generate mask in ndarray formatvar mask = masker;// save the mask as GeoTIFFmasker;
Five methods are provided for masking:
getFillMask()(for filled pixels)
LandsatConfidence class provide the definition of the confidence that certain condition exists at the pixel:
LandsatConfidence.high(66% - 100% confidence)
LandsatConfidence.medium(33% - 66% confidence)
LandsatConfidence.low(0% - 33% confidence)
For more detail about the definition, please visit the USGS Landsat website;
These five methods would return a ndarray mask.
If a mask that matches multiple conditions is desired, the function
getMultiMask() could help:
var mask = masker;
MODIS Land Products
By using the lower level
Masker class, the masking of MODIS land product QA band is supported. Because node-gdal doesn't support HDF format, you need to convert the QA band to a GeoTIFF first using like QGIS,
A handy class
ModisMasker is provided for particularly masking the quality of land products:
var qm = ;var Masker = qmModisMasker;var Quality = qmModisQuality;// read the band file to initializevar masker = 'MODIS_QC_Band.tif';// generate mask in ndarray formatvar mask = masker;// save the mask as GeoTIFFmasker;
ModisQuality provides the definition of pixel quality:
ModisQuality.high: corrected product produced at ideal quality for all bands
ModisQuality.medium: corrected product produced at less than ideal quality for some or all bands
ModisQuality.low: corrected product not produced due to some reasons for some or all bands
ModisQuality.low_cloud: corrected product not produced due to cloud effects for all bands
Masking other than the product quality is not directly provided because of the variety of bit structure for different products.
A low-level method is available to extract mask with the understand of bit structure:
var masker = 'modis_qa_band.tif';var mask = masker;
getMask(bitPos, bitLen, value) function use to bit mask to extract quality mask:
bitPos: the start position of quality assessment bits
bitLen: the length of all used quality assessment bits
value: the desired bit value (in integer)
For the detail explanation, please read MODIS Land Product QA Tutorial.
Looking for command line tool?
If the command line tool is wanted, please use pymasker.
You are a GIS guy and want something GIS?
Take a look at the arcmasker, the ArcMap toolbox that uses the same mechanism.