// sentinel2 ndwi
//哨兵2去云处理
var s2_rmcloud = function(image) {
var quality = image.select("QA60").unmask();
return image.updateMask(quality.eq(0));
};
//在原影像中加入一个新的波段,命名为NDWI
var s2_ndwi = function(image) {
return image.addBands(image.normalizedDifference(["B3", "B8"]).rename("NDWI"));
};
//sentinel2 and roi 过滤筛选哨兵2影像
var s2_col = ee.ImageCollection("COPERNICUS/S2");
var roi = ee.Geometry.Point([117.0703125,38.09133660751176]);
var s2_nocloud = s2_col.map(s2_rmcloud)
.filterBounds(roi)
.filterDate("2017-01-01", "2017-09-24");
var ndwi = s2_nocloud.map(s2_ndwi).select("NDWI").reduce(ee.Reducer.mean());
var visParam = {
min: -0.5,
max: 0.5,
palette: ['00FFFF', '0000FF']
};
Map.addLayer(ndwi, visParam, "ndwi");
Map.centerObject(roi, 9);
//展示关心区域roi在1.1-9.23日之间的的NDWI值序列
var ndwi_list = s2_nocloud.filterDate("2017-01-01", "2017-09-23")
.map(function(image) {
var ndwi = image.normalizedDifference(['B3', 'B5']).rename('NDWI');
return image.addBands(ndwi);
});
var chart1 = ui.Chart.image.series({
imageCollection: ndwi_list.select('NDWI'),
region: roi,
reducer: ee.Reducer.mean(),
scale: 30
}).setOptions({title: 'NDWI IMAGE SERIES'});
print(chart1);
var chart2 = ui.Chart.image.doySeries({
imageCollection: ndwi_list.select('NDWI'),
region:roi,
regionReducer: ee.Reducer.mean(),
scale:30
}).setOptions({title: "ROI NDWI EACH DAY SERIES"})
print(chart2)