The eodata module provides core objects for handling remotely sensing multi-temporal data (such as satellite imagery).
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.
add_feature(feature_type, feature_name, value)¶
Sets EOPatch[feature_type][feature_name] to the given value.
Joins all data from two EOPatches and returns a new EOPatch.
If timestamps don’t match it will try to join all time-dependent features with the same name.
Note: In general the data won’t be deep copied. Deep copy will only happen when merging time-dependent features along time
A method that concatenates two numpy array along first axis.
- data1 (numpy.ndarray) – Numpy array of shape (times1, height, width, n_features)
- data2 – Numpy array of shape (times2, height, width, n_features)
Numpy array of shape (times1 + times2, height, width, n_features)
Removes all frames from the EOPatch with a date not found in the provided timestamps list.
Parameters: timestamps (list of datetime objects) – keep frames with date found in this list Returns: set of removed frames’ dates Return type: set of datetime objects
Returns the array of corresponding feature.
Returns a list of all non-empty features of EOPatch.
The elements are either only FeatureType or a pair of FeatureType and feature name.
Returns: list of features Return type: list(FeatureType or (FeatureType, str))
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.
Returns: A dictionary of features Return type: dict(FeatureType: str or True)
Returns a tuple of spatial dimension (height, width) of a feature.
The feature has to be spatial or time dependent.
load(path, features=Ellipsis, lazy_loading=False, mmap=False)¶
Loads EOPatch from disk.
Removes the feature
feature_namefrom dictionary of
rename_feature(feature_type, feature_name, new_feature_name)¶
Renames the feature
new_feature_namefrom dictionary of
:param new_feature_name : New Name of the feature of the attribute :type feature_name: str
Resets the values of the given feature type.
Parameters: feature_type (FeatureType) – Type of a feature
save(path, features=Ellipsis, file_format=<FileFormat.NPY: 'npy'>, overwrite_permission=<OverwritePermission.ADD_ONLY: 0>, compress_level=0)¶
Saves EOPatch to disk.
- path (str) – Location on the disk
- features – A collection of features types specifying features of which type will be saved. By default
all features will be saved. :type features: list(FeatureType) or list((FeatureType, str)) or … :param file_format: File format :type file_format: FileFormat or str :param overwrite_permission: A level of permission for overwriting an existing EOPatch :type overwrite_permission: OverwritePermission or int :param compress_level: A level of data compression and can be specified with an integer from 0 (no compression)to 9 (highest compression).
Parameters: new_bbox – new bbox Type: new_bbox: BBox
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