Google Earth Engine(GEE)学习笔记1.影像加载去云筛选导出
作者:互联网
加载影像
//加载Landsat8
var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
//加载sentinel
var imageCollection = ee.ImageCollection("COPERNICUS/S1_GRD"),
var imageCollection2 = ee.ImageCollection("COPERNICUS/S2"),
var imageCollection3 = ee.ImageCollection("COPERNICUS/S2_SR");
影像去云函数
//Landsat8去云
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);
}
//Sentinel去云
var cloudfunction_ST2 = function(image){
//use add the cloud likelihood band to the image
var quality = image.select("QA60").unmask();
//get pixels above the threshold
var cloud01 = quality.gt(0);
//create a mask from high likelihood pixels
var cloudmask = image.mask().and(cloud01.not());
//mask those pixels from the image
return image.updateMask(cloudmask);
};
影像筛选显示
//定义时间节点
var startdate = ee.Date.fromYMD(2020,9,1);
var enddate = ee.Date.fromYMD(2020,10,30);
//landsat8
//影像筛选
var l8Imgs = l8 .filterBounds(roi)
.filterDate(startdate, enddate)
.filterMetadata('CLOUD_COVER','less_than',5);
Map.setCenter( 107.753, 34.238, 4);
Map.addLayer( L8, {bands:'B4,B3,B2', min:0, max:0.2}, 'Original Images' );
//sentinel
//s1为从GEE 数据集导入的Sentinel 1数据
var Sentinel1_VV = s1.filterBounds(roi)
.filterDate(startdate, enddate)
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.select('VV')
.median();
var Sentinel1_VH = s1.filterBounds(roi)
.filterDate(startdate, enddate)
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
.select('VH')
.median();
//s2为从GEE 数据集导入的Sentinel 2数据
var Sentinel2 = s2.filterBounds(roi)
.filterDate(startdate, enddate)
.map(cloudfunction_ST2)
.median();
影像导出
//影像数据集下载
//影像集合导出方法
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(table),
description: indexs[i],
fileNamePrefix: indexs[i],
region: table,
scale: 30,
crs: "EPSG:4326",
maxPixels: 1e13
});
}
});
}
exportImageCollection(l8Imgs);
标签:Engine,startdate,Google,enddate,ee,image,GEE,var,影像 来源: https://blog.csdn.net/ZZSOGA/article/details/120403728