eolearn.mask.masking

Module for creating mask features

class eolearn.mask.masking.JoinMasksTask(input_features, output_feature, join_operation='and')[source]

Bases: ZipFeatureTask

Joins together masks with the provided logical operation.

Parameters:
  • input_features (FeaturesSpecification) – Mask features to be joined together.

  • output_feature (Feature) – Feature to which to save the joined mask.

  • join_operation (Literal['and', 'or', 'xor'] | Callable) – How to join masks. Supports ‘and’, ‘or’, ‘xor’, or a Callable object.

zip_method(*masks)[source]

Joins masks using the provided operation

Parameters:

masks (ndarray) –

Return type:

ndarray

class eolearn.mask.masking.MaskFeatureTask(feature, mask_feature, mask_values, no_data_value=nan)[source]

Bases: 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 (SingleFeatureSpec) – A feature to be masked with optional new feature name

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

  • mask_values (Iterable[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:

eopatch (EOPatch) – eopatch to be processed

Returns:

Same eopatch instance with masked feature

Return type:

EOPatch

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

A general masking function

Parameters:
  • data (ndarray) – A data feature

  • mask (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

Return type:

ndarray