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