I want to create an image collection where all the median images can get stored so that later on it can be exported to drive.

Link to my code: https://code.earthengine.google.com/4dc5685ed79044086587d811c4ee584f

//cloud mask along with function to add image as layer in the collection
function addImage(img) 
var id = img.id;
var image = ee.Image(img.id);

var cloudBitMask = ee.Number(2).pow(10).int();
var cirrusBitMask = ee.Number(2).pow(11).int();
var qa = image.select('QA60');
Map.addLayer(qa.bitwiseAnd(cloudBitMask).neq(0), {}, 'clouds');
Map.addLayer(qa.bitwiseAnd(cirrusBitMask).neq(0), {}, 'cirrus');

function maskS2clouds(image) 
var qa = image.select('QA60');
var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
return image.updateMask(mask);

var cloudMasked = sentinel.filterBounds(agra).map(maskS2clouds);
var median = cloudMasked.median();
, {bands: ['B4', 'B3', 'B2'], max: 2000}, 'median');

Your Answer

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

Browse other questions tagged or ask your own question.