朋友们好,本次我们基于Landsat和Sentinel数据,去云计算NDWI,并导出水体提取结果的栅格数据。您只需要导入研究区table,更改时间段运行。归一化水体指数(NDWI)是遥感影像分析中常用的指数,主要用于识别和提取水体。NDWI通过比较可见光波段(绿波段)与近红外波段(NIR)的反射率差异,突出水体与非水体区域的区别。水体在近红外波段的反射率较低,而在绿波段的反射率较高,因此NDWI能够有效地识别水域。该指数在水体监测、水资源管理以及环境变化研究中有着广泛应用。![]()
var studyArea = table;
function calculateNDWI(image, bands) {
var ndwi = image.normalizedDifference(bands).rename('NDWI');
return image.addBands(ndwi);
}
function processSentinel2() {
return ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
.filterDate('2023-03-01', '2023-05-31')
.filterBounds(studyArea)
.map(function(image) {
var cloudMask = image.select('QA60').bitwiseAnd(1 << 10).eq(0)
.and(image.select('QA60').bitwiseAnd(1 << 11).eq(0));
return image.updateMask(cloudMask);
})
.map(function(image) { return calculateNDWI(image, ['B3', 'B8']); })
.select('NDWI')
.mean()
.clip(studyArea);
}
function processLandsat8() {
return ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
.filterDate('2023-03-01', '2023-05-31')
.filterBounds(studyArea)
.map(function(image) {
var opticalBands = image.select(['SR_B.*']).multiply(0.0000275).add(-0.2);
var thermalBands = image.select(['ST_B.*']).multiply(0.00341802).add(149.0);
return image.addBands(opticalBands, null, true).addBands(thermalBands, null, true);
})
.map(function(image) { return calculateNDWI(image, ['SR_B3', 'SR_B5']); })
.select('NDWI')
.mean()
.clip(studyArea);
}
var sentinel2NDWI = processSentinel2();
var landsatNDWI = processLandsat8();
Map.centerObject(studyArea, 10);
Map.addLayer(sentinel2NDWI, {min: -1, max: 1, palette: ['green', 'white', 'blue']}, 'Sentinel-2 NDWI');
Map.addLayer(landsatNDWI, {min: -1, max: 1, palette: ['green', 'white', 'blue']}, 'Landsat 8 NDWI');
Export.image.toDrive({
image: sentinel2NDWI.gt(0).selfMask(),
description: "Water_Bodies_Study_Area_2023_Sentinel2",
scale: 30,
region: studyArea,
fileFormat: 'GeoTIFF',
maxPixels: 1e9
});
Export.image.toDrive({
image: landsatNDWI.gt(0).selfMask(),
description: "Water_Bodies_Study_Area_2023_Landsat8",
scale: 30,
region: studyArea,
fileFormat: 'GeoTIFF',
maxPixels: 1e9
});
![]()