classMask#

geetools.ImageAccessor.classMask(class_info, classes=None, band=0)#

Create a mask using the class information.

In this case there is no option for “all” or “any” because class bands cannot contain 2 classes in the same pixel value.

Parameters:
  • class_info (dict) – class information (client-side only).

  • classes (Optional[list]) – name of the classes to use for the mask. If None it will use all classes in bits_info.

  • band (str | int) – name of the bit band. Defaults to first band.

Example

import ee, geetools
from geetools.utils import initialize_documentation

initialize_documentation()

class_info = {
  '2': 'dark',
  '3': 'shadow',
  '7': 'clouds_low',
  '8': 'clouds_mid',
  '9': 'clouds_high',
  '10': 'cirrus'
}
image = ee.Image("COPERNICUS/S2_SR_HARMONIZED/20230120T142709_20230120T143451_T18GYT")
decoded = image.geetools.classMask(class_info, classes=["dark", "shadow"], band="SCL")
decoded.getInfo()
{'type': 'Image',
 'bands': [{'id': 'mask',
   'data_type': {'type': 'PixelType', 'precision': 'int', 'min': 0, 'max': 1},
   'crs': 'EPSG:32718',
   'crs_transform': [20, 0, 699960, 0, -20, 5300020]}]}