eolearn.io.sentinelhub_process

Input tasks that collect data from Sentinel-Hub Process API

eolearn.io.sentinelhub_process.get_available_timestamps(bbox, config, data_collection, time_difference, time_interval=None, maxcc=None)[source]

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

Parameters
  • bbox (BBox) – Bounding box

  • time_interval (different input formats available (e.g. (str, str), or (datetime, datetime)) – Time interval to query available satellite data from

  • data_collection (DataCollection) – Source of requested satellite data.

  • maxcc (float) – Maximum cloud coverage, in ratio [0, 1], default is None

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

  • config (SHConfig) – Sentinel Hub Config

Returns

list of datetimes with available observations

class eolearn.io.sentinelhub_process.SentinelHubInputBaseTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Base class for Processing API input tasks

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

  • size (tuple(int, int)) – Number of pixels in x and y dimension.

  • resolution (float or (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 (str) – Path to cache_folder. If set to None (default) requests will not be cached.

  • config (SHConfig or None) – An instance of SHConfig defining the service

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

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

Main execute method for the Process API tasks

static check_timestamp_difference(timestamp1, timestamp2)[source]

Raises an error if the two timestamps are not the same

class eolearn.io.sentinelhub_process.SentinelHubEvalscriptTask(*args, **kwargs)[source]

Bases: eolearn.io.sentinelhub_process.SentinelHubInputBaseTask

Process API task to download data using evalscript

Parameters
  • features – Features to construct from the evalscript.

  • evalscript (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 (DataCollection) – Source of requested satellite data.

  • size (tuple(int, int)) – Number of pixels in x and y dimension.

  • resolution (float or (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 (float) – Maximum cloud coverage, a float in interval [0, 1]

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

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

  • config (SHConfig or None) – An instance of SHConfig defining the service

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

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

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

class eolearn.io.sentinelhub_process.SentinelHubInputTask(*args, **kwargs)[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 (DataCollection) – Source of requested satellite data.

  • size (tuple(int, int)) – Number of pixels in x and y dimension.

  • resolution (float or (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 (tuple(sentinelhub.FeatureType, str)) – Target feature into which to save the downloaded images.

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

  • additional_data (list[tuple(sentinelhub.FeatureType, str)]) – A list of additional data to be downloaded, such as SCL, SNW, dataMask, etc.

  • evalscript (str or None) – An optional parameter to override an evascript that is generated by default

  • maxcc (float) – Maximum cloud coverage.

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

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

  • config (SHConfig or None) – An instance of SHConfig defining the service

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

  • bands_dtype (type or None) – 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 (str) – Mosaicking order, which has to be either ‘mostRecent’, ‘leastRecent’ or ‘leastCC’.

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

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(*args, **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 (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 (DataCollection) – Source of requested satellite data.

  • size (tuple(int, int)) – Number of pixels in x and y dimension.

  • resolution (float or (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 (float) – Maximum cloud coverage, a float in interval [0, 1]

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

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

  • config (SHConfig or None) – An instance of SHConfig defining the service

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

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

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

class eolearn.io.sentinelhub_process.SentinelHubSen2corTask(*args, **kwargs)[source]

Bases: eolearn.io.sentinelhub_process.SentinelHubInputTask

Adds SCL (scene classification), CLD (cloud probability) or SNW (snow probability) (or any 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