0

I am trying to apply a cloud cover to exclude clouds values from my graphs, using a Sentinel-2 image collection. I know ho to apply to a single image, but if I put an image collection instead of a single image I get this error:

masked: Layer error: Image.select, argument 'input': Invalid type. Expected type: Image. Actual type: ImageCollection.

This is the code:

// Define a location:
var point = ee.Geometry.Point([1.15529,47.034695]); //[Latitude,Longitude]
Map.addLayer(point)

// Load image Collection:
var imageCollection = ee.ImageCollection("COPERNICUS/S2_SR").filterDate('2017-01-01','2017-12-31');
var imageCollection = imageCollection.filterBounds(point);

print(imageCollection)

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


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

var masked = cld.sclMask(['cloud_low', 'cloud_medium', 'cloud_high', 'shadow'])(imageCollection)
Map.addLayer(masked, {bands:['B4', 'B3', 'B2'], min:0, max:5000}, 'masked')

How can I fix this?

1 Answer 1

1

You need to call the specific function and iterate over the image collection using .map() function:

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

var sentinel2function = cloud_masks.sentinel2();

var col = imageCollection.map(sentinel2function);

Map.addLayer(imageCollection, {bands:['B4', 'B3', 'B2'], min:0, max:5000}, 'test image');
Map.addLayer(col, {bands:['B4', 'B3', 'B2'], min:0, max:5000}, 'test image masked');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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