eolearn.mask.masking

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.

Parameters
  • 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.

zip_method(*masks)[source]

Joins masks using the provided operation

Parameters

masks (numpy.ndarray) –

Return type

numpy.ndarray

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

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