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.

  • 1
    Are you planning to combine the data somehow? or you want just a 3 bands image? – Rodrigo E. Principe Sep 12 '18 at 16:51
  • i want the three images that compose the image collection (one for each month), converts into one image that contains the data for the three (summary: three becoming one) – Vann Sep 12 '18 at 23:46
  • Ok, but still not answering. You need one value per pixel? or 3 values per pixel? have you worked with raster images before? – Rodrigo E. Principe Sep 13 '18 at 1:17
  • one value per pixel. yes I have (ENVI, ARCGIS, QGIS, etc).. I thought I've answered your question. no need to be so condescending – Vann Sep 13 '18 at 2:49
  • Sorry, I am just trying to help. The problem here is that you have 3 values (one for each month) and you want just 1 value. Assuming that your interest is in the burnDate band of MCD64A1, what will be the only value for those 3 months? the latest date? – Rodrigo E. Principe Sep 13 '18 at 3:29
// 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([]));
| improve this answer | |
  • Great! everyday you learn something new =) I didn't know that using ee.Image([]) (an image with no bands) would make the loop start from the first image of the collection. Splitting the collection was a pain. Thanks! – Rodrigo E. Principe Sep 15 '18 at 18:12
  • 1
    Some explanation about the code would be helpful. – Stefan Sep 16 '18 at 4:56
  • 2
    Learn more from the iterate() docs: the user guide and/or the API reference. – Nicholas Clinton Sep 17 '18 at 3:07
  • I also obtained the result using: var merged = MOD1.iterate(mergeBands, MOD1.first()); – shahryar Apr 12 at 20:31
  • Really helpful answer, thanks! – Waleed93 Jul 2 at 8:29

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.