[GIS] Image collection to Single Image in Google Earth Engine

google-earth-engineimagemodis

I'm stuck with an issue in google earth engine.

I'm working with MODIS Burned Area Monthly Global 500m, for a certain polygon area:

var MOD = ee.ImageCollection('MODIS/006/MCD64A1');
var MOD1 = MOD.filterDate('2005-06-21', '2005-09-31');
var MODlim1 = MOD.map(function(img) {return img.clip(lim)})

The problem is the image collection has three images (one for each month), and I need to convert this into a single image, which contains the burned area for three images in only one.
Anyone knows what function can be helpful in this situation?
I need to repeat this for every year (until 2018), so with a single image, it would be easier to analyze the data.

Best Answer

// UPDATE: The easiest way is now toBands().
var merged = MOD1.toBands();

// For completeness, this is the iterate() way:
var mergeBands = function(image, previous) {
  return ee.Image(previous).addBands(image);
};

var merged = MOD1.iterate(mergeBands, ee.Image([]));
Related Question