var roi = table;//table为自己上传的矢量边界
//去云算法
/*function maskS2clouds(image) {
var qa = image.select('QA60');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
*/
// 筛选影像
var s2_collection = ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(roi)
.filterDate('2017-04-01', '2017-09-30')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 90))
//.map(function(image){
// return image.clip(roi)//按研究区域裁剪
// })
//.map(maskS2clouds);
print("s2_collection",s2_collection)
var rgbVis = {
min: 0.0,
max: 0.3,
bands: ['B4', 'B3', 'B2'],
};
Map.addLayer(s2_collection, rgbVis, 's2_collection');
Map.centerObject(roi,7)
//显示矢量边界
var styling = {color:"red",fillColor:"00000000"};
//Map.addLayer(roi.style(styling),{},"boundary");
//影像集合导出方法
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.select(['B8']),
description: indexs[i],
fileNamePrefix: indexs[i],
folder: 'S2_images',
region: roi,
scale: 10,
crs: "EPSG:4326",
maxPixels: 1e13
});
}
});
}
exportImageCollection(s2_collection);
GEE下载哨兵2数据的代码
最新推荐文章于 2024-07-19 21:25:05 发布