I'm new to GEE and got stucked running the followed code. My problem is: Get L5 collection, selecting B7 channel > Mask clouds and shadows based on pixel_qa product > Convert the image collection to a multiband image (only B7) > Export to drive.

The code is running but I can't display the layer or export it. Error message: Cannot add an object of type ComputedObject to the map.

Does anyone know how can I do this?

// Test area
var geometry = /* color: #98ff00 */ee.Geometry.Polygon(
    [[[-49.7, -19.3],
      [-49.7, -18.9],
      [-50.1, -18.9],
      [-50.1, -19.3]]]);

// Function to mask clouds
var maskClouds = function(image){
  var pixel_qa = image.select('pixel_qa');    
  return image.updateMask(pixel_qa.lt(69))

// Import L5 collections 
var collection5 = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
    .filterDate('2008-01-01', '2008-12-31') 
    .filter(ee.Filter.eq('WRS_PATH', 222))
    .filter(ee.Filter.eq('WRS_ROW', 73))
    .select('B7', 'pixel_qa')                               

// Image collection to Image
var empty = ee.Image().select();
var landsat5 = collection5.iterate(function(image, result) {
  return ee.Image(result).addBands(image.select(['B7']));    
    }, empty); 

// Display
Map.addLayer(landsat5, {min:0, max:1000})
Map.setCenter(-49.9,-19.1, 10);

// Export image
  image: landsat5,
  description: 'landsat5',
  region: geometry,
  folder: 'test',
  maxPixels: 1e12,
  scale: 30

2 Answers 2


Casting may solve the error you encountered, but the function you're looking for is imageCollection.toBands().


The iterate function returns a Computed Object, you could see that in the docs. Therefore, you will have to cast the output of the iterate function to the ee.Object it actually should be (you as a user know it should be an image). You can check that using ee.Object.name():

// Check what kind of object it is:
print(landsat5.name()); // ComputedObject
// Cast to an image
landsat5 = ee.Image(landsat5);
print(landsat5.name()); // Image

Link script

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.