eolearn.features.temporal_features

Module handling processing of temporal features

class eolearn.features.temporal_features.AddSpatioTemporalFeaturesTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Task that implements and adds to eopatch the spatio-temporal features proposed in [1].

This task assumes that the argmax/argmin of NDVI, NDVI slope and B4 are present in eopatch. The computed spatio-temporal features correspond to the concatenation of reflectance (green, red, near-infrared and short-wave infrared in [1]) values taken at dates where:

  1. NDVI is maximum

  2. NDVI is minimum

  3. red reflectances are maximum

  4. NDVI slope is maximum

  5. NDVI slope is minimum

The features are added to the data_timeless attribute dictionary of eopatch.

[1] Waldner et al. “Automated annual cropland mapping using knowledge-based temporal features”, ISPRS Journal of Photogrammetry and Remote Sensing, 2015

Class constructor

Initialisation of task variables. The name of the dictionary keys that will be used for the computation of the features needs to be specified. These features are assumed to be existing in the eopatch. The indices of the reflectances to be used as features is an input parameter. If None is used, the data attribute is supposed to have 13 bands and indices for green/red/infrared/short-wave-infrared are used.

Parameters
  • argmax_ndvi (str) – Name of argmax_ndvi feature in eopatch. Default is ‘ARGMAX_NDVI’

  • argmin_ndvi (str) – Name of argmin_ndvi feature in eopatch. Default is ‘ARGMIN_NDVI’

  • argmax_red (str) – Name of argmax_red feature in eopatch. Default is ‘ARGMAX_B4’

  • argmax_ndvi_slope (str) – Name of argmax_ndvi_slope feature in eopatch. Default is ‘ARGMAX_NDVI_SLOPE’

  • argmin_ndvi_slope (str) – Name of argmin_ndvi_slope feature in eopatch. Default is ‘ARGMIN_NDVI_SLOPE’

  • feats_feature (str) – Name of feature containing spatio-temporal features. Default is ‘STF’

  • data_feature (str) – Name of feature containing the reflectances to be used as features. Default is ‘BANDS-S2-L1C’

  • indices (None or list of int) – List of indices from data_feature to be used as features. Default is None, corresponding to [2, 3, 7, 11] indices

execute(eopatch)[source]

Compute spatio-temporal features for input eopatch

Parameters

eopatch – Input eopatch

Returns

eopatch with computed spatio-temporal features

class eolearn.features.temporal_features.AddMaxMinTemporalIndicesTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Task to compute temporal indices of the maximum and minimum of a data feature

This class computes the argmax and argmin of a data feature in the input eopatch (e.g. NDVI, B4). The data can be masked out by setting the mask_data flag to True. In that case, the ‘VALID_DATA’ mask feature is used for masking. If mask_data is False, the data is masked using the ‘IS_DATA’ feature.

Two new features are added to the data_timeless attribute.

Task constructor

Parameters
  • data_feature (str) – Name of the feature in data used for computation of max/min. Default is ‘NDVI’

  • data_index (int) – Index of to be extracted from last dimension in data_feature. If None, last dimension of data array is assumed ot be of size 1 (e.g. as in NDVI). Default is None

  • amax_data_feature (str) – Name of feature to be associated to computed feature of argmax values

  • amin_data_feature (str) – Name of feature to be associated to computed feature of argmin values

  • mask_data – Flag specifying whether to mask data with ‘VALID_DATA’ mask. If False, the ‘IS_DATA’ mask is used

execute(eopatch)[source]

Compute argmax/argmin of specified data_feature and data_index

Parameters

eopatch – Input eopatch

Returns

eopatch with added argmax/argmin features

class eolearn.features.temporal_features.AddMaxMinNDVISlopeIndicesTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Task to compute the argmax and armgin of the NDVI slope

This task computes the slope of the NDVI feature using central differences. The NDVI feature can be masked using the ‘VALID_DATA’ mask. Current implementation loops through every location of eopatch, and is therefore slow.

The NDVI slope at date t is comuted as $(NDVI_{t+1}-NDVI_{t-1})/(date_{t+1}-date_{t-1})$.

Task constructor

Parameters
  • data_feature (str) – Name of data feature with NDVI values. Default is ‘NDVI’

  • argmax_feature (str) – Name of feature with computed argmax values of the NDVI slope

  • argmin_feature (str) – Name of feature with computed argmin values of the NDVI slope

  • mask_data – Flag for masking NDVI data. Default is True

execute(eopatch)[source]

Computation of NDVI slope using finite central differences

This implementation loops through every spatial location, considers the valid NDVI values and approximates their first order derivative using central differences. The argument of min and max is added to the eopatch.

The NDVI slope at date t is comuted as $(NDVI_{t+1}-NDVI_{t-1})/(date_{t+1}-date_{t-1})$.

Parameters

eopatch – Input eopatch

Returns

eopatch with NDVI slope argmin/argmax features