I am working with Imerg data and after calculating the total rainfall from monthly averages there is an error while after I run the export.image.toDrive
. The error is:
Attempted 1 time Error: Image.clipToBoundsAndScale, argument 'input': Invalid type. Expected type: Image. Actual type: ImageCollection. (Error code: 3)
Also, the projection is giving me this error:
Line 36: projection is not defined
Here is the code I am using
//Total Rainfall
var imerg = ee.ImageCollection("NASA/GPM_L3/IMERG_MONTHLY_V06").select('precipitation');
var year = 2019;
var startDate = ee.Date.fromYMD(year, 1, 1);
var endDate = startDate.advance(1, 'year');
var filtered = imerg
.filter(ee.Filter.date(startDate, endDate));
var total = function(img){
var year = 2019;
var startDate = ee.Date.fromYMD(year, 1, 1);
var endDate = startDate.advance(1, 'year');
var hoursInyear = endDate.difference(startDate, 'hours');
return img.addBands(img.multiply(hoursInyear).rename('precip_mm_month'));
};
filtered = filtered.map(total);
var palette = [
'000096','0064ff', '00b4ff', '33db80', '9beb4a',
'ffeb00', 'ffb300', 'ff6400', 'eb1e00', 'af0000'
];
var precipitationVis = {min: 0.0, max: 10000, palette: palette};
Map.addLayer(filtered, {bands:'precip_mm_month', palette:palette, min:0, max: 5000})
print(filtered);
var projection = total.select('precip_mm_month').projection().getInfo();
Export.image.toDrive({
image: filtered,
maxPixels: 1e13,
description: 'Precipitation_2019',
crs: projection.crs,
crsTransform: projection.transform
region: roi,
});
As the error message states, an ImageCollection
was found where an Image
is needed. Specifically, Export.image.toDrive()
can only be used to export single images, not image collections.
If you want to export the same (mosaiced) view that you get from Map.addLayer()
, then use
Export.image.toDrive({
image: filtered.mosaic(),
...
I can't help you with your additional problem because the code you have presented has different errors than you mentioned (total
is not an image but a function, so total.select()
fails).