In the article of RSEI a while ago, everyone wanted to download the images of RESI every year. Many people encountered the problem that the images could not be downloaded. I will give an example here. Let’s look at the problem first:
这里的错误: Error: Image. clipToBoundsAndScale, argument ' input': Invalid type. Expected type: Image<unknown bands>. Actual type: ImageCollection. (Error code: 3)
In fact, we need to briefly clarify the problem here, that is, the image download we want to obtain, and we have obtained a lot of scene images through traversal, so we have no way to download it. In fact, there is a good way to use mosaic. , we need to mosaic multiple images together, and then download them according to one image.
for example:
var Years = ee.List.sequence(2000,2020); // 生成逐年的List
// 逐年进行Map操作,遍历下载影像
var yearlist = Years.getInfo();
print(yearlist);
var year_imgcol = ee.ImageCollection.fromImages(yearlist.map(function(year) {
var img = VI.filter(ee.Filter.calendarRange(year, year, 'year')).mosaic();
var y=img.set({name:ee.String(ee.Number(year).int())})
Export.image.toDrive({
image:img,
description:'rsei'+year.toString(),
region:sa,
scale:500,
maxPixels:1e13
});
Map.addLayer(img, ndviVis, 'rsei');
return img;
}));
It's this code:
var img = VI.filter (ee.Filter.calendarRange (year, year, 'year'));
var img = VI.filter (ee.Filter.calendarRange (year, year, 'year')). mosaic ();
mosaic()
Composites all the images in a collection, using the mask.
Composite all images in a collection using masks.
Arguments:
this:collection (ImageCollection):
The collection to mosaic.
Returns: Image
Finally succeeded: