I'm trying to map an isolated month of imagery reduced with a median reducer in Earth Engine. However, when I try to incorporate code from this approach (also tried using the listOfImages[2] approach in the other answer to that question) I can't map the resulting object. It's confusing because when I print the object, it shows that I have an image, but I get the error:

Cannot add an object of type ComputedObject to the map.

I looked into this solution to a similar error, but I don't think my code is mapping a list object, based on the fact that print("March LS8",Mar); returns a 3-band Image. Ultimately I want to maintain my 12-image imageCollection ("monthVis") for exporting purposes.

Reproducible code:

// Define (example) region of interest
var ROI = ee.FeatureCollection('TIGER/2016/Counties')
  .filter(ee.Filter.eq('NAME', 'Waldo'));
Map.centerObject(ROI, 9);

//// Image manipulation
// Create clipping function so we're just dealing with the ROI
var clipper = function(image){
  return image.clip(ROI);

// Visualization function for median imageCollections
var vizzer = function(x){
  return x.visualize({bands: ['B4_median', 'B3_median', 'B2_median'], min: 0, max: 7000});

//// Load imagery
// Load a raw Landsat scene and display it.
var raw = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
  .filterDate("2013-01-01", "2018-12-31")

//// Rearrange imagery
// Based on code by Nicholas Clinton https://gis.stackexchange.com/a/258379/67264
var months = ee.List.sequence(1, 12);
var byMonth = ee.ImageCollection.fromImages(
      months.map(function (m) {
        return raw.filter(ee.Filter.calendarRange(m, m, 'month'))
                    .set('month', m);

//// Look at imagery
print("monthlyAggs", byMonth);
var monthVis = byMonth.map(vizzer);
print("monthVis", monthVis);

// Map specified layer using a List.
var listOfImages = monthVis.toList(monthVis.size());
print("listOfImages", listOfImages);
var Mar = listOfImages.get(2);
print("March LS8",Mar); // Returns an image
Map.addLayer(Mar, {}, "March LS8"); // Returns an error

1 Answer 1


the functionget of a list returns an object of type Object (or computed object). But Map.addLayer takes either Collection/Feature/Image/MapId. Since your computed object is an image, all you need to do is cast it to an image object.

var Mar = ee.Image(listOfImages.get(2));

Your Answer

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

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