Module for creating mask features

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

Bases: eolearn.core.core_tasks.ZipFeatureTask

Joins together masks with the provided logical operation.

  • input_features – Mask features to be joined together.

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

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


Joins masks using the provided operation


masks (numpy.ndarray) –

Return type


class eolearn.mask.masking.MaskFeatureTask(feature, mask_feature, mask_values, no_data_value=nan)[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

  • 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


The same eopatch instance with a masked array


Mask values of feature according to the mask_values in mask_feature


eopatcheopatch to be processed


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

  • 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