geetools.bitreader
#
Bit Reader module.
Module Contents#
Classes#
Bit Reader. |
- class geetools.bitreader.BitReader(options, bit_length=None)[source]#
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’) ``` >>FalseTODO missing docstring.
- decodeImage(image, qa_band)[source]#
Get an Image with one band per category in the Bit Reader.
- Parameters:
bit_reader (BitReader) – the bit reader
qa_band (str) – name of the band that holds the bit information
- Returns:
the image with the decode bands added
- encodeAnd(*args)[source]#
Decodes a combination of the given categories. returns a list of.
possible values .
- encodeBand(category, mask, name=None)[source]#
Make an image in which all pixels have the value for the given.
category.
- Parameters:
category (str) – the category to encode
mask (ee.Image) – the mask that indicates which pixels encode
name (str) – name of the resulting band. If None it’ll be the same as ‘mask’
- Returns:
A one band image
- Return type:
ee.Image
- encodeNot(*args)[source]#
Given a set of categories return a list of values that DO NOT.
match with any .
- encodeOr(*args)[source]#
Decodes a combination of the given categories. returns a list of.
possible values .
- static getBin(bit, nbits=None, shift=0)[source]#
from https://stackoverflow.com/questions/699866/python-int-to-binary.