Skip to content

GEE image does not display after applying the cloud mask based on SCL band #4

@Rohaifa

Description

@Rohaifa

I am new in GEE and I want to work on NDVI time series, but before doing this I want to preprocess Sentinel-2A images using a cloud mask based on Scene Classification (SCL) band.

The code bellow imports three types of masks, apply one of them and visualize the image before and after applying the mask.

My question is that when I use Mask2 or Mask3, the image after applying the mask does not display. However, Mask1 works perfectly!

Here is the link to the code in GEE: https://code.earthengine.google.com/429990239fd25488aa9614bc87685385

Please, I need your help to solve this issue.
`
var cld = require('users/fitoprincipe/geetools:cloud_masks');

var col = ee.ImageCollection('COPERNICUS/S2_SR');

var img = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2018-04-01', '2018-04-30')
.median().select('TCI_R','TCI_G','TCI_B');
print('img', img);
Map.addLayer(img);

// Mask useless classes from built-in Scene Classification
var Mask1 = function(image) {
var masked = cld.sentinel2(['opaque', 'cirrus'])(image)
return masked
}

var Mask2 = function(image) {
var masked = cld.sclMask(['cloud_low', 'cloud_medium',
'cloud_high', 'cirrus', 'shadow', 'saturated', 'dark',
'snow'])(image)
return masked
}

var Mask3 = function(image) {
var masked = cld.hollstein_S2(['cloud', 'snow', 'shadow', 'water', 'cirrus'])(image)
return masked
}

// Apply the mask
var Masked_col = col.map(Mask2);
var msk_img = Masked_col.filterDate('2018-04-01', '2018-04-30')
.median().select('TCI_R','TCI_G','TCI_B');
print('masked img', msk_img);
Map.addLayer(msk_img);
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions