前一段时间RSEI的文章中,大家想下载每一年的RESI的影像,有很多人遇到了影像无法下载的问题,我在这里举个例子,先看问题:
这里的错误: Error: Image. clipToBoundsAndScale, argument ' input': Invalid type. Expected type: Image<unknown bands>. Actual type: ImageCollection. (Error code: 3)
其实,这里需要给大家简单明确一下问题的所在,就是我们要获取的影像下载,而我们通过遍历却获取了很多景影像,所以我们就没有办法下载,其实有一个很好的办法,就用镶嵌,我们要把多景影像镶嵌在一起,然后就可以按照一景影像下载。
举个例子:
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;
}));
就是这句代码:
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.
使用掩码对一个集合中的所有图像进行合成。
Arguments:
this:collection (ImageCollection):
The collection to mosaic.
Returns: Image
最后成功了: