Google Earth Engine – Fix Invalid Argument Error for Image

errorexportgoogle-earth-engineimagejavascript

I'm trying to export an image for some SST temperatures for a given region ( and imported table EEZ) but I'm getting the error;

Error: Invalid argument: 'image' must be of type Image

Map.addLayer(EEZ, {}, 'EEZ')
Map.addLayer(Chagos, {}, 'Chagos')

//load an image
var sst = ee.ImageCollection('NASA/OCEANDATA/MODIS-Aqua/L3SMI')
.select('sst')
.filterDate('2017-04-01', '2017-04-30')
.filterBounds(EEZ)
.map(function(image){return image.clip(EEZ)}) ;

print('sst', sst)

Map.setCenter(72.25, -6.8, 6); //lat, long, zoom
Map.addLayer (sst, {'min': 23, 'max': 34, 'palette':"0000ff,32cd32,ffff00,ff8c00,ff0000"});

Export.image.toDrive({
image: sst,
description: 'sst Apr 2017',
scale: 500,
region: EEZ
});

After a search I found this post, and changed the export image code to just select the bands I want, as suggested, using the code below. However I still get the same error.

Export.image.toDrive({
image: sst.select('sst'),
description: 'sst Apr 2017',
scale: 500,
region: EEZ
});

Best Answer

You are trying to export an ImageCollection. The MODIS product you are using has daily images, thus there are 29 images in your collection. The export to Drive only allows images, not collections, hence the error you see.

You can either combine this collection of 29 single-band images into an image with 29 bands or reduce the collection to a single image for export.

This would be the code to export the mean temperature for the month of april.

Export.image.toDrive({
image: sst.select('sst').mean(),
description: 'sst Apr 2017',
scale: 500,
region: EEZ
});
Related Question