Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Rohaifa opened this issue Apr 12, 2020 · 2 comments

Comments

@Rohaifa
Copy link

Rohaifa commented Apr 12, 2020

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);
`

@fitoprincipe
Copy link
Owner

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

@Rohaifa
Copy link
Author

Rohaifa commented Apr 14, 2020

Hello @fitoprincipe, I got the same error! But how can I fix it? I really need to apply the second Mask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants