Different mask shapes

Dear Sentinelhub-Team,

I experienced a problem by using some of your eo-learn functions:

from eolearn.io import AddSen2CorClassificationFeature
from eolearn.mask import AddCloudMaskTask, get_s2_pixel_cloud_detector

By executing the following EO-Tasks, I retrieve different shapes within the resulting EO-Patch:

# Add SCL from sen2cor
add_SCL = AddSen2CorClassificationFeature(sen2cor_classification='SCL',

# Add Sen2Cloudless
cloud_classifier = get_s2_pixel_cloud_detector(average_over=2,
add_clm = AddCloudMaskTask(cloud_classifier, 'BANDS-S2CLOUDLESS',
                           cm_size_y='80m', cm_size_x='80m',
                           cmask_feature='CLM',  # cloud mask name
                           cprobs_feature='CLP',  # cloud prob. map name

When printing the resulting EO-Patch, I get the following:

  data: {
    CLP: numpy.ndarray(shape=(37, 70, 73, 1), dtype=float32)
    MY_S2_BANDS: numpy.ndarray(shape=(37, 70, 73, 9), dtype=uint8)
    RPI: numpy.ndarray(shape=(37, 70, 73, 1), dtype=float64)
  mask: {
    CLM: numpy.ndarray(shape=(37, 70, 73, 1), dtype=bool)
    IS_DATA: numpy.ndarray(shape=(37, 70, 73, 1), dtype=bool)
    SCL: numpy.ndarray(shape=(37, 70, 72, 1), dtype=int32)
  scalar: {}
  label: {}
  vector: {}
  data_timeless: {}
  mask_timeless: {}
  scalar_timeless: {}
  label_timeless: {}
  vector_timeless: {}
  meta_info: {
    maxcc: 1.0
    service_type: 'wcs'
    size_x: '10m'
    size_y: '10m'
    time_difference: datetime.timedelta(seconds=3600)
    time_interval: ['2019-05-01', '2019-07-30']
  bbox: BBox(((622033.5364121953, 5352274.161972809), (622762.6876688242, 5352975.174904556)), crs=CRS('32633'))
  timestamp: [datetime.datetime(2019, 5, 1, 10, 7, 19), ..., datetime.datetime(2019, 7, 30, 10, 7, 20)], length=37

Here you can see that mask.CLM and mask.SCL have slightly different shapes.
CLM seems to have the same shape than the rest of the “data”, but SCL seems to have one column less.

Is this problem on your or on my side and if I can avoid it, can you tell me how?


Hi Johannes,

The reason that the masks have different shapes is not a problem on your side. The issue is in the OGC-based eo-learn task implementation. Task AddSen2CorClassificationFeature expects that the last channel will be the transparency mask but OGC parameter transparent=True is not supported anymore. Therefore it just takes a slice from a spatial dimension (i.e. reducing dimension from 73 to 72) and thinking that is a mask.

Our recent focus for feature developments in eo-learn has been based on the Sentinel Hub Processing API, and we don’t intend to maintain or fix OGC-based tasks in eo-learn anymore. Therefore I would suggest that you use the Process API based functions to do the processing steps you are interested in.

For example, to fetch the SCL band, I recommend using SentinelHubInputTask. This example specifically shows you how to get the SCL band.

Let me know if anything needs clarifying :slight_smile:


@maxim.lamare thank you very much for the good explanation :slight_smile:
Then I will try the SentinelHubInputTask instead