Home

Awesome

node-qa-masker

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.

Installation

npm install qa-masker

Use Example

Landsat 8

The LandsatMasker class provides the functionality to load and generate masks from the Quality Assessment band of Landsat 8 OLI image.

var qm = require('qa-masker');
var Masker = qm.LandsatMasker;
var Confidence = qm.LandsatConfidence;

// read the band file to initialize
var masker = new Masker('LC80170302016198LGN00_BQA.TIF');

// generate mask in ndarray format
var mask = masker.getWaterMask(Confidence.high);

// save the mask as GeoTIFF
masker.saveAsTif(mask, 'test.tif');

Five methods are provided for masking:

The LandsatConfidence class provide the definition of the confidence that certain condition exists at the pixel:

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.getMultiMask([
  { type: 'could', confidence: LandsatConfidence.high },
  { type: 'cirrus', confidence: LandsatConfidence.medium }
]);

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 = require('qa-masker');
var Masker = qm.ModisMasker;
var Quality = qm.ModisQuality;

// read the band file to initialize
var masker = new Masker('MODIS_QC_Band.tif');

// generate mask in ndarray format
var mask = masker.getQaMask(Quality.high);

// save the mask as GeoTIFF
masker.saveAsTif(mask, 'mask.tif');

The ModisQuality provides the definition of pixel quality:

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 = new Masker('modis_qa_band.tif');
var mask = masker.getMask(0, 2, 2);

getMask(bitPos, bitLen, value) function use to bit mask to extract quality mask:

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.