npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qa-masker

v0.2.3

Published

Generate masks from Landsat and MODIS quality accessment band

Downloads

9

Readme

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:

  • getCloudMask(confidence)

  • getCirrusMask(confidence)

  • getWaterMask(confidence)

  • getVegMask(confidence) (for vegetation)

  • getSnowMask(confidence)

  • getFillMask() (for filled pixels)

The 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)

  • LandsatConfidence.undefined

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:

  • 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 = 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:

  • 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.