eolearn.io.local_io

Module containing tasks used for reading and writing to disk

class eolearn.io.local_io.BaseLocalIoTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Base abstract class for local IO tasks

Parameters
  • feature ((FeatureType, str)) – Feature which will be exported or imported

  • folder (str) – A directory containing image files or a folder of an image file

  • image_dtype (numpy.dtype) – Type of data to be exported into tiff image or imported from tiff image

  • no_data_value (int or float) – Value of undefined pixels

  • config (SHConfig) – A configuration object containing AWS credentials

abstract execute(eopatch, **kwargs)[source]

Execute of a base class is not implemented

class eolearn.io.local_io.ExportToTiffTask(*args, **kwargs)[source]

Bases: eolearn.io.local_io.BaseLocalIoTask

Task exports specified feature to Geo-Tiff.

When exporting multiple times OR bands, the Geo-Tiff band counts are in the expected order. However, when exporting multiple times AND bands, the order obeys the following pattern:

T(1)B(1), T(1)B(2), …, T(1)B(N), T(2)B(1), T(2)B(2), …, T(2)B(N), …, …, T(M)B(N)

where T and B are the time and band indices of the array, and M and N are the lengths of these indices, respectively

Parameters
  • feature ((FeatureType, str)) – Feature which will be exported

  • folder (str) – A directory containing image files or a path of an image file. If the file extension of the image file is not provided, it will default to “.tif”. If a “*” wildcard or a datetime.strftime substring (e.g. “%Y%m%dT%H%M%S”) is provided in the image file, an EOPatch feature will be split over multiple GeoTiffs each corresponding to a timestamp, and the stringified datetime will be appended to the image file name.

  • band_indices (tuple or list or None) – Bands to be added to tiff image. Bands are represented by their 0-based index as tuple in the inclusive interval form (start_band, end_band) or as list in the form [band_1, band_2,…,band_n].

  • date_indices (tuple or list or None) – Dates to be added to tiff image. Dates are represented by their 0-based index as tuple in the inclusive interval form (start_date, end_date) or a list in the form [date_1, date_2,…,date_n].

  • crs (CRS or str or None) – CRS in which to reproject the feature before writing it to GeoTiff

  • fail_on_missing (bool) – should the pipeline fail if a feature is missing or just log warning and return

  • compress (str or None) – the type of compression that rasterio should apply to exported image.

  • image_dtype (numpy.dtype) – Type of data to be exported into tiff image

  • no_data_value (int or float) – Value of pixels of tiff image with no data in EOPatch

  • config (SHConfig) – A configuration object containing AWS credentials

execute(eopatch, *, filename=None)[source]

Execute method

Parameters
  • eopatch (EOPatch) – input EOPatch

  • filename (str or None) – A filename of tiff file or None if entire path has already been specified in folder parameter of task initialization. If the file extension of the image file is not provided, it will default to “.tif”. If a “*” wildcard or a datetime.strftime substring (e.g. “%Y%m%dT%H%M%S”) is provided in the image file, an EOPatch feature will be split over multiple GeoTiffs each corresponding to a timestamp, and the stringified datetime will be appended to the image file name.

Returns

Unchanged input EOPatch

Return type

EOPatch

class eolearn.io.local_io.ImportFromTiffTask(*args, **kwargs)[source]

Bases: eolearn.io.local_io.BaseLocalIoTask

Task for importing data from a Geo-Tiff file into an EOPatch

The task can take an existing EOPatch and read the part of Geo-Tiff image, which intersects with its bounding box, into a new feature. But if no EOPatch is given it will create a new EOPatch, read entire Geo-Tiff image into a feature and set a bounding box of the new EOPatch.

Note that if Geo-Tiff file is not completely spatially aligned with location of given EOPatch it will try to fit it as best as possible. However it will not do any spatial resampling or interpolation on Geo-TIFF data.

Parameters
  • feature ((FeatureType, str)) – EOPatch feature into which data will be imported

  • folder (str) – A directory containing image files or a path of an image file

  • timestamp_size (int) – In case data will be imported into time-dependant feature this parameter can be used to specify time dimension. If not specified, time dimension will be the same as size of FeatureType.TIMESTAMP feature. If FeatureType.TIMESTAMP does not exist it will be set to 1. When converting data into a feature channels of given tiff image should be in order T(1)B(1), T(1)B(2), …, T(1)B(N), T(2)B(1), T(2)B(2), …, T(2)B(N), …, …, T(M)B(N) where T and B are the time and band indices.

  • image_dtype (numpy.dtype) – Type of data of new feature imported from tiff image

  • no_data_value (int or float) – Values where given Geo-Tiff image does not cover EOPatch

  • config (SHConfig) – A configuration object containing AWS credentials

execute(eopatch=None, *, filename=None)[source]

Execute method which adds a new feature to the EOPatch

Parameters
  • eopatch (EOPatch or None) – input EOPatch or None if a new EOPatch should be created

  • filename (str, list of str or None) – filename of tiff file or None if entire path has already been specified in folder parameter of task initialization.

Returns

New EOPatch with added raster layer

Return type

EOPatch

class eolearn.io.local_io.BaseLocalIo(*args, **kwargs)[source]

Bases: eolearn.io.local_io.BaseLocalIoTask

A deprecated version of BaseLocalIoTask

Parameters
  • feature ((FeatureType, str)) – Feature which will be exported or imported

  • folder (str) – A directory containing image files or a folder of an image file

  • image_dtype (numpy.dtype) – Type of data to be exported into tiff image or imported from tiff image

  • no_data_value (int or float) – Value of undefined pixels

  • config (SHConfig) – A configuration object containing AWS credentials

class eolearn.io.local_io.ExportToTiff(*args, **kwargs)[source]

Bases: eolearn.io.local_io.ExportToTiffTask

A deprecated version of ExportToTiffTask

Parameters
  • feature ((FeatureType, str)) – Feature which will be exported

  • folder (str) – A directory containing image files or a path of an image file. If the file extension of the image file is not provided, it will default to “.tif”. If a “*” wildcard or a datetime.strftime substring (e.g. “%Y%m%dT%H%M%S”) is provided in the image file, an EOPatch feature will be split over multiple GeoTiffs each corresponding to a timestamp, and the stringified datetime will be appended to the image file name.

  • band_indices (tuple or list or None) – Bands to be added to tiff image. Bands are represented by their 0-based index as tuple in the inclusive interval form (start_band, end_band) or as list in the form [band_1, band_2,…,band_n].

  • date_indices (tuple or list or None) – Dates to be added to tiff image. Dates are represented by their 0-based index as tuple in the inclusive interval form (start_date, end_date) or a list in the form [date_1, date_2,…,date_n].

  • crs (CRS or str or None) – CRS in which to reproject the feature before writing it to GeoTiff

  • fail_on_missing (bool) – should the pipeline fail if a feature is missing or just log warning and return

  • compress (str or None) – the type of compression that rasterio should apply to exported image.

  • image_dtype (numpy.dtype) – Type of data to be exported into tiff image

  • no_data_value (int or float) – Value of pixels of tiff image with no data in EOPatch

  • config (SHConfig) – A configuration object containing AWS credentials

class eolearn.io.local_io.ImportFromTiff(*args, **kwargs)[source]

Bases: eolearn.io.local_io.ImportFromTiffTask

A deprecated version of ImportFromTiffTask

Parameters
  • feature ((FeatureType, str)) – EOPatch feature into which data will be imported

  • folder (str) – A directory containing image files or a path of an image file

  • timestamp_size (int) – In case data will be imported into time-dependant feature this parameter can be used to specify time dimension. If not specified, time dimension will be the same as size of FeatureType.TIMESTAMP feature. If FeatureType.TIMESTAMP does not exist it will be set to 1. When converting data into a feature channels of given tiff image should be in order T(1)B(1), T(1)B(2), …, T(1)B(N), T(2)B(1), T(2)B(2), …, T(2)B(N), …, …, T(M)B(N) where T and B are the time and band indices.

  • image_dtype (numpy.dtype) – Type of data of new feature imported from tiff image

  • no_data_value (int or float) – Values where given Geo-Tiff image does not cover EOPatch

  • config (SHConfig) – A configuration object containing AWS credentials