The eodata module provides core objects for handling remote sensing multi-temporal data (such as satellite imagery).
- class eolearn.core.eodata.EOPatch(*, data=NOTHING, mask=NOTHING, scalar=NOTHING, label=NOTHING, vector=NOTHING, data_timeless=NOTHING, mask_timeless=NOTHING, scalar_timeless=NOTHING, label_timeless=NOTHING, vector_timeless=NOTHING, meta_info=NOTHING, bbox=None, timestamp=NOTHING)
The basic data object for multi-temporal remotely sensed data, such as satellite imagery and its derivatives.
The EOPatch contains multi-temporal remotely sensed data of a single patch of earth’s surface defined by the bounding box in specific coordinate reference system. The patch can be a rectangle, polygon, or pixel in space. The EOPatch object can also be used to store derived quantities, such as for example means, standard deviations, etc., of a patch. In this case the ‘space’ dimension is equivalent to a pixel.
Primary goal of EOPatch is to store remotely sensed data, usually of a shape n_time x height x width x n_features images, where height and width are the numbers of pixels in y and x, n_features is the number of features (i.e. bands/channels, cloud probability, etc.), and n_time is the number of time-slices (the number of times this patch was recorded by the satellite; can also be a single image)
In addition to that other auxiliary information is also needed and can be stored in additional attributes of the EOPatch (thus extending the functionality of numpy ndarray). These attributes are listed in the FeatureType enum.
Currently, the EOPatch object doesn’t enforce that the length of timestamp be equal to n_times dimensions of numpy arrays in other attributes.
Method generated by attrs for class EOPatch.
- copy(features=Ellipsis, deep=False)
Get a copy of the current EOPatch.
features (object supported by the
FeatureParser) – Features to be copied into a new EOPatch. By default, all features will be copied.
deep (bool) – If True it will make a deep copy of all data inside the EOPatch. Otherwise, only a shallow copy of EOPatch will be made. Note that BBOX and TIMESTAMP will be copied even with a shallow copy.
An EOPatch copy.
- Return type
Resets the values of the given feature type.
feature_type (FeatureType) – Type of feature
Returns a dictionary of all non-empty features of EOPatch.
The elements are either sets of feature names or a boolean True in case feature type has no dictionary of feature names.
A dictionary of features
- Return type
dict(FeatureType: str or True)
- get_spatial_dimension(feature_type, feature_name)
Returns a tuple of spatial dimension (height, width) of a feature.
The feature has to be spatial or time dependent.
- get_feature_list() List[Union[eolearn.core.constants.FeatureType, Tuple[eolearn.core.constants.FeatureType, str]]]
Returns a list of all non-empty features of EOPatch.
The elements are either only FeatureType or a pair of FeatureType and feature name.
list of features
- save(path, features=Ellipsis, overwrite_permission=OverwritePermission.ADD_ONLY, compress_level=0, filesystem=None)
Method to save an EOPatch from memory to a storage.
path (str) – A location where to save EOPatch. It can be either a local path or a remote URL path.
compress_level (int) – A level of data compression and can be specified with an integer from 0 (no compression) to 9 (highest compression).
filesystem (fs.FS or None) – An existing filesystem object. If not given it will be initialized according to the path parameter.
- static load(path, features=Ellipsis, lazy_loading=False, filesystem=None)
Method to load an EOPatch from a storage into memory.
path (str) – A location from where to load EOPatch. It can be either a local path or a remote URL path.
features (object) – A collection of features to be loaded. By default, all features will be loaded.
lazy_loading (bool) – If True features will be lazy loaded.
- Return type
- merge(*eopatches, features=Ellipsis, time_dependent_op=None, timeless_op=None)
Merge features of given EOPatches into a new EOPatch.
eopatches (EOPatch) – Any number of EOPatches to be merged together with the current EOPatch
features (object) – A collection of features to be merged together. By default, all features will be merged.
time_dependent_op (str or Callable or None) –
An operation to be used to join data for any time-dependent raster feature. Before joining time slices of all arrays will be sorted. Supported options are:
None (default): If time slices with matching timestamps have the same values, take one. Raise an error otherwise.
’concatenate’: Keep all time slices, even the ones with matching timestamps
’min’: Join time slices with matching timestamps by taking minimum values. Ignore NaN values.
’max’: Join time slices with matching timestamps by taking maximum values. Ignore NaN values.
’mean’: Join time slices with matching timestamps by taking mean values. Ignore NaN values.
’median’: Join time slices with matching timestamps by taking median values. Ignore NaN values.
timeless_op (str or Callable or None) –
An operation to be used to join data for any timeless raster feature. Supported options are:
None (default): If arrays are the same, take one. Raise an error otherwise.
’concatenate’: Join arrays over the last (i.e. bands) dimension
’min’: Join arrays by taking minimum values. Ignore NaN values.
’max’: Join arrays by taking maximum values. Ignore NaN values.
’mean’: Join arrays by taking mean values. Ignore NaN values.
’median’: Join arrays by taking median values. Ignore NaN values.
A dictionary with EOPatch features and values
- Return type
- get_time_series(ref_date=None, scale_time=1)
Returns a numpy array with seconds passed between the reference date and the timestamp of each image.
An array is constructed as time_series[i] = (timestamp[i] - ref_date).total_seconds(). If reference date is None the first date in the EOPatch’s timestamp is taken. If EOPatch timestamp attribute is empty the method returns None.
ref_date (datetime object) – reference date relative to which the time is measured
scale_time (int) – scale seconds by factor. If 60, time will be in minutes, if 3600 hours
Removes all frames from the EOPatch with a date not found in the provided timestamps list.
timestamps (list of datetime objects) – keep frames with date found in this list
set of removed frames’ dates
- Return type
set of datetime objects
- plot(feature, *, times: Union[List[int], slice, None] = None, channels: Union[List[int], slice, None] = None, channel_names: Optional[List[str]] = None, rgb: Optional[Tuple[int, int, int]] = None, backend: Union[str, PlotBackend] = 'matplotlib', config: Optional[BasePlotConfig] = None, **kwargs) object
Plots an EOPatch feature.
feature – A feature in the EOPatch.
times – A list or a slice of indices on temporal axis to be used for plotting. If not provided all indices will be used.
channels – A list or a slice of indices on channels axis to be used for plotting. If not provided all indices will be used.
channel_names – Names of channels of the last dimension in the given raster feature.
rgb – If provided, it should be a list of 3 indices of RGB channels to be plotted. It will plot only RGB images with these channels. This only works for raster features with spatial dimension.
backend – A type of plotting backend.
config – A configuration object with advanced plotting parameters.
kwargs – Parameters that are specific to a specified plotting backend.
A plot object that depends on the backend used.