FeatureCollection的批量下载
https://zhuanlan.zhihu.com/p/80340644
var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR");
var roi = /* color: #d63000 */ee.Geometry.Polygon(
[[[115.64960937499995, 39.112756306811285],
[116.28681640624995, 39.163883889810315],
[116.21540527343745, 39.58850167846649],
[115.70454101562495, 39.6054326422912]]]);
Map.centerObject(roi, 8);
function rmL8Cloud(image) {
var cloudShadowBitMask = (1 << 3);
var cloudsBitMask = (1 << 5);
var qa = image.select('pixel_qa');
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0));
return image.updateMask(mask);
}
var l8Imgs = l8.filterBounds(roi)
.filterDate("2018-1-1", "2018-3-1")
.map(rmL8Cloud);
print("l8Imgs", l8Imgs);
Map.addLayer(l8Imgs, {min:0, max:3000, bands:["B4","B3","B2"]}, "l8Imgs");
Map.addLayer(roi, {color: "red"}, "roi");
//影像集合导出方法
function exportImageCollection(imgCol) {
var indexList = imgCol.reduceColumns(ee.Reducer.toList(), ["system:index"])
.get("list");
indexList.evaluate(function(indexs) {
for (var i=0; i<indexs.length; i++) {
var image = imgCol.filter(ee.Filter.eq("system:index", indexs[i])).first();
image = image.toInt16();
Export.image.toDrive({
image: image.clip(roi),
description: indexs[i],
fileNamePrefix: indexs[i],
region: roi,
scale: 30,
crs: "EPSG:4326",
maxPixels: 1e13
});
}
});
}
exportImageCollection(l8Imgs);