0

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);
Map.addLayer(image);

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(
         qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask);
}

var cloudMasked = sentinel.filterBounds(agra).map(maskS2clouds);
var median = cloudMasked.median();
Map.addLayer(median
, {bands: ['B4', 'B3', 'B2'], max: 2000}, 'median');
print(median);
}
Jyoti
  • 41
  • 2
  • 4
  • What do you mean by 'all' the median images? In this manner, you just create one composite image. – Kuik May 16 '19 at 15:37
  • If you look at the code, you'll see that for this particular code 3 median images are generated for every cloudy image. – Jyoti May 16 '19 at 15:50
  • However, those median images are generated from axactly the same images, so they are similar: https://code.earthengine.google.com/e8864b672add14cc2d58f36a4c264df1. Do you want to create median images from a specific time interval? – Kuik May 17 '19 at 07:25
  • Yeah, I realised this later that the median images are same. Thanks But I would like to explore as to how to create median images from different time intervals. – Jyoti May 17 '19 at 11:37
  • There a tons of example on stackExchange: https://gis.stackexchange.com/questions/308369/reducing-hourly-rainfall-data-to-monthly-data-for-particular-period-of-time-and/308422#308422, https://gis.stackexchange.com/questions/315354/getting-weekly-mean-composite-in-google-earth-engine, https://gis.stackexchange.com/questions/321919/10-days-composite-from-sentinel-2-images-collection – Kuik May 17 '19 at 11:55
  • Thanks I'm still doubtful about the properties of the 3 median images. Will they have exactly the same properties or somewhat different? – Jyoti May 18 '19 at 12:51

0 Answers0