0

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)) .clip(geometry); }; // 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') .filterBounds(geometry).map(maskClouds); // 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 print(landsat5) Map.addLayer(landsat5, {min:0, max:1000}) Map.setCenter(-49.9,-19.1, 10); // Export image Export.image.toDrive({ image: landsat5, description: 'landsat5', region: geometry, folder: 'test', maxPixels: 1e12, scale: 30 }); 

2 Answers 2

3

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

0

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.