0
var s2SR_list = s2SR.toList(s2SR.size());

var s2SRMasked = s2SR_list.map(function (img) {
  
  return cld.sclMask(['cloud_low', 'cloud_medium', 'cloud_high', 'shadow'])(img);
  
});


print('s2SRMasked', s2SRMasked);

How can I see this 2SRMasked images?

2

Although the use of for-loops is discouraged in Earth Engine, this is one of situations where it can be useful. On the other hand, your above code snippet is not very useful. It is necessary complete code in your previous question. However, it produces 250 images for complete Image Collection. So, I'm going to display only ten of them in the for-loop (with its respective names for better visualization). Complete code looks as follows:

var geometry = ee.Geometry.Point([-109.647021484375, 39.40057454539126]);

var cld = require('users/fitoprincipe/geetools:cloud_masks');

var s2SR = ee.ImageCollection('COPERNICUS/S2_SR')
              //filter start and end date
             .filter(ee.Filter.calendarRange(2013,2021,'year'))
             .filter(ee.Filter.calendarRange(1,12,'month'))
             //filter according to drawn boundary
             .filterBounds(geometry)
             .filterMetadata('CLOUD_COVERAGE_ASSESSMENT', 'less_than',50);
//var first = ee.Image.constant(0) // init image

print("s2SR", s2SR);

//var first = ee.Image(s2SR.get(0))
var test_image = s2SR.first();

Map.addLayer(test_image, {bands:['B4', 'B3', 'B2'], min:0, max:8000}, 'test image');

// adding mNDWI function
var addMNDWI = function(image) {
  var mndwi = ee.Image(image).normalizedDifference(['B3', 'B11']).rename('MNDWI');
  return ee.Image(image).addBands(mndwi);
};
 var mndwı=ee.ImageCollection(test_image)
             .map(addMNDWI);
 Map.addLayer(mndwı, {bands:['B4', 'B3', 'B2'], min:0, max:400}, 'mndwı');


var masked = cld.sclMask(['cloud_low', 'cloud_medium', 'cloud_high', 'shadow'])(test_image);

print("masked", masked);
Map.addLayer(masked, {bands:['B4', 'B3', 'B2'], min:0, max:3000}, 'masked');

var s2SR_list = s2SR.toList(s2SR.size());

var s2SRMasked = s2SR_list.map(function (img) {
  
  return cld.sclMask(['cloud_low', 'cloud_medium', 'cloud_high', 'shadow'])(img);
  
});

print('s2SRMasked', s2SRMasked);

for (var iter= 0; iter < 10; iter += 1) {
  
  var img = ee.Image(s2SRMasked.get(iter));
  
  var date = ee.Date(img.get('system:time_start'));

  var name_image = ee.String("image_")
    .cat(ee.Number(iter).int())
    .cat('_')
    .cat(date.format()
    .slice(0,10)).getInfo();

  Map.addLayer(img, {bands: ['B4', 'B3', 'B2'], min:245, max: 5000}, name_image);

}

After running above code in GEE code editor, I got result of following image. It can be observed that it was displayed a "stack" of 10 images; as it expected.

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.