geetools.bitreader.BitReader#

class geetools.bitreader.BitReader(options, bit_length=None)#

Bases: object

Bit Reader.

Initializes with parameter options, which must be a dictionary with the following format:

keys must be a str with the bits places, example: ‘0-1’ means bit 0 and bit 1

values must be a dictionary with the bit value as the key and the category (str) as value. Categories must be unique.

  • Encode: given a category/categories return a list of possible values

  • Decode: given a value return a list of categories

Example

MOD09 (http://modis-sr.ltdri.org/guide/MOD09_UserGuide_v1_3.pdf) (page 28, state1km, 16 bits):

``` options = {

‘0-1’: {0:’clear’, 1:’cloud’, 2:’mix’}, ‘2-2’: {1:’shadow’}, ‘8-9’: {1:’small_cirrus’, 2:’average_cirrus’, 3:’high_cirrus’} }

reader = BitReader(options, 16)

print(reader.decode(204)) ` >>['shadow', 'clear'] ` print(reader.match(204, ‘cloud’) ``` >>False

TODO missing docstring.

Methods#

decode(value)

given a value return a list with all categories.

decodeImage(image, qa_band)

Get an Image with one band per category in the Bit Reader.

decodeKey(key)

decodes an option's key into a list.

encode(cat)

Given a category, return the encoded value (only).

encodeAnd(*args)

Decodes a combination of the given categories. returns a list of.

encodeBand(category, mask[, name])

Make an image in which all pixels have the value for the given.

encodeNot(*args)

Given a set of categories return a list of values that DO NOT.

encodeOne(cat)

Given a category, return a list of values that match it.

encodeOr(*args)

Decodes a combination of the given categories. returns a list of.

getBin(bit[, nbits, shift])

from https://stackoverflow.com/questions/699866/python-int-to-binary.

match(value, category)

given a value and a category return True if the value includes.