eolearn.mask.masking

Module for creating mask features

class eolearn.mask.masking.AddValidDataMaskTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

EOTask for adding custom mask array used to filter reflectances data

This task allows the user to specify the criteria used to generate a valid data mask, which can be used to filter the data stored in the FeatureType.DATA

Constructor of the class requires a predicate defining the function used to generate the valid data mask. A predicate is a function that returns the truth value of some condition.

An example predicate could be an and operator between a cloud mask and a snow mask.

Parameters
  • predicate (func) – Function used to generate a valid_data mask

  • valid_data_feature (str) – Feature which will store valid data mask

execute(eopatch)[source]

Execute predicate on input eopatch

Parameters

eopatch – Input eopatch instance

Returns

The same eopatch instance with a mask.valid_data array computed according to the predicate

class eolearn.mask.masking.MaskFeatureTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Masks out values of a feature using defined values of a given mask feature.

As an example, it can be used to mask the data feature using values from the Sen2cor Scene Classification Layer (SCL).

Contributor: Johannes Schmid, GeoVille Information Systems GmbH, 2018

Parameters
  • feature ((FeatureType, str) or (FeatureType, str, str)) – A feature to be masked with optional new feature name

  • mask_feature ((FeatureType, str)) – Masking feature. Values of this mask will be used to mask values of feature

  • mask_values (list of int) – List of values of mask_feature to be used for masking feature

  • no_data_value (float) – Value that replaces masked values in feature. Default is NaN

Returns

The same eopatch instance with a masked array

execute(eopatch)[source]

Mask values of feature according to the mask_values in mask_feature

Parameters

eopatcheopatch to be processed

Returns

Same eopatch instance with masked feature

eolearn.mask.masking.apply_mask(data, mask, old_value, new_value, data_type, mask_type)[source]

A general masking function

Parameters
  • data (numpy.ndarray) – A data feature

  • mask (numpy.ndarray) – A mask feature

  • old_value (float) – An old value in data that will be replaced

  • new_value (float) – A new value that will replace the old value in data

  • data_type (FeatureType) – A data feature type

  • mask_type (FeatureType) – A mask feature type

class eolearn.mask.masking.MaskFeature(*args, **kwargs)[source]

Bases: eolearn.mask.masking.MaskFeatureTask

A deprecated version of MaskFeatureTask

Parameters
  • feature ((FeatureType, str) or (FeatureType, str, str)) – A feature to be masked with optional new feature name

  • mask_feature ((FeatureType, str)) – Masking feature. Values of this mask will be used to mask values of feature

  • mask_values (list of int) – List of values of mask_feature to be used for masking feature

  • no_data_value (float) – Value that replaces masked values in feature. Default is NaN

Returns

The same eopatch instance with a masked array