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
});