var s2Sr = ee.ImageCollection('COPERNICUS/S2'); var s2Clouds = ee.ImageCollection('COPERNICUS/S2_CLOUD_PROBABILITY'); var START_DATE = ee.Date('2018-01-01'); var END_DATE = ee.Date('2018-12-31'); var MAX_CLOUD_PROBABILITY = 65; function maskClouds(img) { var clouds = ee.Image(img.get('cloud_mask')).select('probability'); var isNotCloud = clouds.lt(MAX_CLOUD_PROBABILITY); return img.updateMask(isNotCloud); } // The masks for the 10m bands sometimes do not exclude bad data at // scene edges, so we apply masks from the 20m and 60m bands as well. // Example asset that needs this operation: // COPERNICUS/S2_CLOUD_PROBABILITY/20190301T000239_20190301T000238_T55GDP function maskEdges(s2_img) { return s2_img.updateMask( s2_img.select('B8A').mask().updateMask(s2_img.select('B9').mask())); } // Filter input collections by desired data range and region. var criteria = ee.Filter.and( ee.Filter.bounds(table), ee.Filter.date(START_DATE, END_DATE)); s2Sr = s2Sr.filter(criteria).map(maskEdges); s2Clouds = s2Clouds.filter(criteria); // Join S2 SR with cloud probability dataset to add cloud mask. var s2SrWithCloudMask = ee.Join.saveFirst('cloud_mask').apply({ primary: s2Sr, secondary: s2Clouds, condition: ee.Filter.equals({leftField: 'system:index', rightField: 'system:index'}) }); var s2CloudMasked = ee.ImageCollection(s2SrWithCloudMask).map(maskClouds).median(); var rgbVis = {min: 0, max: 3000, bands: ['B4', 'B3', 'B2']}; var rgbVis = {min: 0, max: 3000, bands: ['B4', 'B3', 'B2']}; Map.addLayer( s2CloudMasked, rgbVis, 'S2 SR masked at ' + MAX_CLOUD_PROBABILITY + '%', true);将合成图像的全波段下载
时间: 2024-02-13 11:05:43 浏览: 182
EE24 Satellite Imagery.docx
要将合成图像的全波段下载,可以使用 `Export.image.toDrive` 方法将影像导出为 Google Drive 上的 GeoTIFF 文件,然后在本地使用 GIS 软件打开。以下是一个示例代码,可以将中值影像导出为 GeoTIFF 文件:
```
// 选择导出区域的几何图形
var geometry = table.geometry();
// 定义导出参数
var exportParams = {
image: s2CloudMasked,
description: 'S2_SR_masked',
folder: 'GEE_exports',
region: geometry,
scale: 10,
maxPixels: 1e13
};
// 开始导出
Export.image.toDrive(exportParams);
```
在这里,我们将中值影像导出为名为 `S2_SR_masked` 的 GeoTIFF 文件,并将其保存在 Google Drive 上的 `GEE_exports` 文件夹中。`region` 参数指定要导出的区域,`scale` 参数指定导出影像的分辨率,`maxPixels` 参数指定导出影像允许的最大像素数。你可以根据自己的需求修改这些参数。
阅读全文