geetools-code-editor
geetools-code-editor copied to clipboard
GEE image does not display after applying the cloud mask based on SCL band
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);
`
Hi @Rohaifa, what is the actual issue? the resulting image is not masked, or it throws an error? I tried and I got an Internal Error
which has been around for a while and is related to GEE servers and not my code
Hello @fitoprincipe, I got the same error! But how can I fix it? I really need to apply the second Mask.