Giter Club home page Giter Club logo

pymasker's Introduction

pymasker

Pymasker is a python package to generate various masks from the Landsat Quality Assessment band and MODIS land products.

Installation

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.

Use Example

Python

For Landsat pre-collection and collection-1 Quality Accessment band

from pymasker import LandsatMasker
from pymasker import LandsatConfidence

# load the QA band directly
#
# The "collection" parameter is required for landsat to specify the collection
# number. Acceptable number: 0 (pre-collection), 1 (collection-1)
#
masker = LandsatMasker('LC80170302014272LGN00_BQA.TIF', collection=0)

# 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')

Command Line

pymasker [source] [input.tif] [output.tif] [options...]

Required arguments:

source SOURCE
  source type: landsat, modis

input INPUT
  input image file path

output OUTPUT
  output raster path

Landsat arguments:

-C, --collection  LANDSAT COLLECTION NUMBER
  collection number of input image: 0 (pre-collection), 1

-c, --confidence CONFIDENCE
  level of confidence that a condition exists in a landsat image:
  high, medium, low, undefined, none

-cv, --confidence_value CONFIDENCE VALUE
   confidence values: -1, 0, 1, 2, 3

-m, --mask MASK
  pre-collection mask: fill, cloud, cirrus, water, snow
  collection-1 mask: fill, no_cloud, cloud, cloud_shadow, cirrus, snow

MODIS arguments:

-q, --quality QUALITY
  Level of data quality of MODIS land products at each pixel:
  high, medium, low, low_cloud

More Detail

The following two articles explains the mechanism behind the tool in detail.

For JavaScript Developer

node-qa-masker provides the same masking functionality in NodeJS.

pymasker's People

Contributors

haoliangyu avatar kbasten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymasker's Issues

Not working with collection-1 Landsat-8 data

Hi,

Firstly let me thank you for this tool. I would like to know if you have any plans of updating it so that its able to work with Landsat-8 collection-1 data.

Regards,
Lufuno

Gdal Issue

Attempting to run this in a juypter notebook and it seems there is an error with gdal within pymasker's build. This problem could be isolated to my computer, but I have done a fresh and the same result occurs.

ModuleNotFoundError: No module named 'gdal'

Any help you could give would be great, thank you so much!

Multimask

Hello,
thank you very much for this nice tool! I'm new to Python, but I managed to get seperate medium and high confidence cloud masks.
I would like to get a raster combining both medium and high confidence pixels.

mask = masker.get_multi_mask(cloud = LandsatConfidence.high, cloud = LandsatConfidence.medium)

This command gives the following ERROR:

SyntaxError: keyword argument repeated

Is it possible to do what I aim for?

Thank you,

Roman

Gdal & Python Versions

Hi! Not an issue but rather a question, I noticed in previous bugs you were using Python 2.7, which GDAL version are you using? Thanks!

Accuracy Testing?

Please opt to delete this (or I can come back and do so) I was just hoping there would be some information on accuracy of this product?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.