eolearn.io.sentinelhub_process

Input tasks that collect data from Sentinel-Hub Process API

class eolearn.io.sentinelhub_process.SentinelHubInputBaseTask(data_collection, size=None, resolution=None, cache_folder=None, config=None, max_threads=None, upsampling=None, downsampling=None, session_loader=None)[source]

Bases: eolearn.core.eotask.EOTask

Base class for Processing API input tasks

Parameters
  • data_collection (sentinelhub.data_collections.DataCollection) – A collection of requested satellite data.

  • size (Optional[Tuple[int, int]]) – Number of pixels in x and y dimension.

  • resolution (Optional[Union[float, Tuple[float, float]]]) – Resolution in meters, passed as a single number or a tuple of two numbers - resolution in horizontal and resolution in vertical direction.

  • cache_folder (Optional[str]) – Path to cache_folder. If set to None (default) requests will not be cached.

  • config (Optional[sentinelhub.config.SHConfig]) – An instance of SHConfig defining the service

  • max_threads (Optional[int]) – Maximum threads to be used when downloading data.

  • upsampling (Optional[sentinelhub.constants.ResamplingType]) – A type of upsampling to apply on data

  • downsampling (Optional[sentinelhub.constants.ResamplingType]) – A type of downsampling to apply on data

  • session_loader (Optional[Callable[[], sentinelhub.download.session.SentinelHubSession]]) – A callable that returns a valid SentinelHubSession, used for session sharing. Creates a new session if set to None, which should be avoided in large scale parallelization.

execute(eopatch=None, bbox=None, time_interval=None, geometry=None)[source]

Main execute method for the Process API tasks. The geometry is used only in conjunction with the bbox and does not act as a replacement.

Parameters
static check_timestamp_difference(timestamp1, timestamp2)[source]

Raises an error if the two timestamps are not the same

class eolearn.io.sentinelhub_process.SentinelHubEvalscriptTask(features=None, evalscript=None, data_collection=None, size=None, resolution=None, maxcc=None, time_difference=None, mosaicking_order=None, cache_folder=None, config=None, max_threads=None, upsampling=None, downsampling=None, aux_request_args=None, session_loader=None)[source]

Bases: eolearn.io.sentinelhub_process.SentinelHubInputBaseTask

Process API task to download data using evalscript

Parameters
  • features (Optional[eolearn.core.constants.FeatureType]) – Features to construct from the evalscript.

  • evalscript (Optional[str]) – Evalscript for the request. Beware that all outputs from SentinelHub services should be named and should have the same name as corresponding feature

  • data_collection (Optional[sentinelhub.data_collections.DataCollection]) – Source of requested satellite data.

  • size (Optional[Tuple[int, int]]) – Number of pixels in x and y dimension.

  • resolution (Optional[Union[float, Tuple[float, float]]]) – Resolution in meters, passed as a single number or a tuple of two numbers - resolution in horizontal and resolution in vertical direction.

  • maxcc (Optional[float]) – Maximum cloud coverage, a float in interval [0, 1]

  • time_difference (Optional[datetime.timedelta]) – Minimum allowed time difference, used when filtering dates, None by default.

  • cache_folder (Optional[str]) – Path to cache_folder. If set to None (default) requests will not be cached.

  • config (Optional[sentinelhub.config.SHConfig]) – An instance of SHConfig defining the service

  • max_threads (Optional[int]) – Maximum threads to be used when downloading data.

  • upsampling (Optional[sentinelhub.constants.ResamplingType]) – A type of upsampling to apply on data

  • downsampling (Optional[sentinelhub.constants.ResamplingType]) – A type of downsampling to apply on data

  • mosaicking_order (Optional[Union[str, sentinelhub.constants.MosaickingOrder]]) – Mosaicking order, which has to be either ‘mostRecent’, ‘leastRecent’ or ‘leastCC’.

  • aux_request_args (Optional[dict]) – a dictionary with auxiliary information for the input_data part of the SH request

  • session_loader (Optional[Callable[[], sentinelhub.download.session.SentinelHubSession]]) – A callable that returns a valid SentinelHubSession, used for session sharing. Creates a new session if set to None, which should be avoided in large scale parallelization.

class eolearn.io.sentinelhub_process.SentinelHubInputTask(data_collection=None, size=None, resolution=None, bands_feature=None, bands=None, additional_data=None, evalscript=None, maxcc=None, time_difference=None, cache_folder=None, config=None, max_threads=None, bands_dtype=None, single_scene=False, mosaicking_order=None, upsampling=None, downsampling=None, aux_request_args=None, session_loader=None)[source]

Bases: eolearn.io.sentinelhub_process.SentinelHubInputBaseTask

Process API input task that loads 16bit integer data and converts it to a 32bit float feature.

Parameters
  • data_collection (Optional[sentinelhub.data_collections.DataCollection]) – Source of requested satellite data.

  • size (Optional[Tuple[int, int]]) – Number of pixels in x and y dimension.

  • resolution (Optional[Union[float, Tuple[float, float]]]) – Resolution in meters, passed as a single number or a tuple of two numbers - resolution in horizontal and resolution in vertical direction.

  • bands_feature (Optional[Tuple[eolearn.core.constants.FeatureType, str]]) – A target feature into which to save the downloaded images.

  • bands (Optional[List[str]]) – An array of band names. If not specified it will download all bands specified for a given data collection.

  • additional_data (Optional[List[Tuple[eolearn.core.constants.FeatureType, str]]]) – A list of additional data to be downloaded, such as SCL, SNW, dataMask, etc.

  • evalscript (Optional[str]) – An optional parameter to override an evalscript that is generated by default

  • maxcc (Optional[float]) – Maximum cloud coverage.

  • time_difference (Optional[datetime.timedelta]) – Minimum allowed time difference, used when filtering dates, None by default.

  • cache_folder (Optional[str]) – Path to cache_folder. If set to None (default) requests will not be cached.

  • config (Optional[sentinelhub.config.SHConfig]) – An instance of SHConfig defining the service

  • max_threads (Optional[int]) – Maximum threads to be used when downloading data.

  • bands_dtype (Optional[List[str]]) – output type of the bands array, if set to None the default is used

  • single_scene (bool) – If true, the service will compute a single image for the given time interval using mosaicking.

  • mosaicking_order (Optional[Union[str, sentinelhub.constants.MosaickingOrder]]) – Mosaicking order, which has to be either ‘mostRecent’, ‘leastRecent’ or ‘leastCC’.

  • upsampling (Optional[sentinelhub.constants.ResamplingType]) – A type of upsampling to apply on data

  • downsampling (Optional[sentinelhub.constants.ResamplingType]) – A type of downsampling to apply on data

  • aux_request_args (Optional[dict]) – a dictionary with auxiliary information for the input_data part of the SH request

  • session_loader (Optional[Callable[[], sentinelhub.download.session.SentinelHubSession]]) – A callable that returns a valid SentinelHubSession, used for session sharing. Creates a new session if set to None, which should be avoided in large scale parallelization.

DTYPE_TO_SAMPLE_TYPE = {<class 'bool'>: 'SampleType.UINT8', <class 'numpy.uint8'>: 'SampleType.UINT8', <class 'numpy.uint16'>: 'SampleType.UINT16', <class 'numpy.float32'>: 'SampleType.FLOAT32'}
generate_evalscript()[source]

Generate the evalscript to be passed with the request, based on chosen bands

class eolearn.io.sentinelhub_process.SentinelHubDemTask(feature=None, data_collection=DataCollection.DEM, **kwargs)[source]

Bases: eolearn.io.sentinelhub_process.SentinelHubEvalscriptTask

Adds DEM data (one of the collections) to

DATA_TIMELESS EOPatch feature.

Parameters
  • features – Features to construct from the evalscript.

  • evalscript – Evalscript for the request. Beware that all outputs from SentinelHub services should be named and should have the same name as corresponding feature

  • data_collection – Source of requested satellite data.

  • size – Number of pixels in x and y dimension.

  • resolution – Resolution in meters, passed as a single number or a tuple of two numbers - resolution in horizontal and resolution in vertical direction.

  • maxcc – Maximum cloud coverage, a float in interval [0, 1]

  • time_difference – Minimum allowed time difference, used when filtering dates, None by default.

  • cache_folder – Path to cache_folder. If set to None (default) requests will not be cached.

  • config – An instance of SHConfig defining the service

  • max_threads – Maximum threads to be used when downloading data.

  • upsampling – A type of upsampling to apply on data

  • downsampling – A type of downsampling to apply on data

  • mosaicking_order – Mosaicking order, which has to be either ‘mostRecent’, ‘leastRecent’ or ‘leastCC’.

  • aux_request_args – a dictionary with auxiliary information for the input_data part of the SH request

  • session_loader – A callable that returns a valid SentinelHubSession, used for session sharing. Creates a new session if set to None, which should be avoided in large scale parallelization.

class eolearn.io.sentinelhub_process.SentinelHubSen2corTask(sen2cor_classification, data_collection=DataCollection.SENTINEL2_L2A, **kwargs)[source]

Bases: eolearn.io.sentinelhub_process.SentinelHubInputTask

Adds SCL (scene classification), CLD (cloud probability) or SNW (snow probability) (or their combination) Sen2Cor classification results to EOPatch’s MASK or DATA feature. The feature is added to MASK (SCL) or DATA (CLD, SNW) feature types of EOPatch. The feature names are set to be SCL, CLD or SNW.

Sen2Cor’s scene classification (SCL) contains 11 classes with the following values and meanings:
  • 1 - SC_SATURATED_DEFECTIVE

  • 2 - SC_DARK_FEATURE_SHADOW

  • 3 - SC_CLOUD_SHADOW

  • 4 - VEGETATION

  • 5 - NOT-VEGETATED

  • 6 - WATER

  • 7 - SC_CLOUD_LOW_PROBA / UNCLASSIFIED

  • 8 - SC_CLOUD_MEDIUM_PROBA

  • 9 - CLOUD_HIGH_PROBABILITY

  • 10 - THIN_CIRRUS

  • 11 - SNOW

Parameters
  • sen2cor_classification (str or [str]) – “SCL” (scene classification), “CLD” (cloud probability) or “SNW” (snow probability) masks to be retrieved. Also, a list of their combination (e.g. [“SCL”,”CLD”])

  • kwargs – Additional arguments that will be passed to the SentinelHubInputTask

eolearn.io.sentinelhub_process.get_available_timestamps(bbox, data_collection, *, time_interval=None, time_difference=datetime.timedelta(days=- 1, seconds=86399), maxcc=None, config=None)[source]

Helper function to search for all available timestamps, based on query parameters.

Parameters
  • bbox (sentinelhub.geometry.BBox) – A bounding box of the search area.

  • data_collection (sentinelhub.data_collections.DataCollection) – A data collection for which to find available timestamps.

  • time_interval (Optional[Tuple[datetime.datetime, datetime.datetime]]) – A time interval from which to provide the timestamps.

  • time_difference (datetime.timedelta) – Minimum allowed time difference, used when filtering dates.

  • maxcc (Optional[float]) – Maximum cloud coverage filter from interval [0, 1], default is None.

  • config (Optional[sentinelhub.config.SHConfig]) – A configuration object.

Returns

A list of timestamps of available observations.

Return type

List[datetime.datetime]