// 定义研究点坐标
var cor = [52.91994991092, 33.56756085477778];
var point = ee.Geometry.Point(cor);
// 加载FAO GAUL数据集并筛选研究区域
var feature = ee.FeatureCollection("FAO/GAUL/2015/level0");
var roi = feature.filterBounds(point);
Map.centerObject(roi);
Map.addLayer(roi);
// 定义时间范围
var time_start = '2001', time_end = '2003';
// 加载MODIS NDVI数据集
var ndvi = ee.ImageCollection("MODIS/061/MOD13A2")
.select(['NDVI'])
.filterDate(time_start, time_end);
// 计算VCI
var ndvi_min = ndvi.min().multiply(0.0001);
var ndvi_max = ndvi.max().multiply(0.0001);
var vci = ndvi.map(function (img) {
var band = img.multiply(0.0001);
var index = band.expression('((ndvi - min)/(max - min))*100.0', {
'ndvi': band,
'min': ndvi_min,
'max': ndvi_max
}).rename('vci');
return index.copyProperties(img, ['system:time_start', 'system:time_end']);
});
// 计算VCI中值
var vci_median = vci.median();
Map.addLayer(vci_median.clip(roi), [], 'vci_median', false);
// 打印VCI直方图
print(
ui.Chart.image.histogram(vci_median, roi, 1000)
);
// VCI分类
var cons = ee.Image.constant(0);
var extreme = cons.where(vci_median.gte(0).and(vci_median.lt(10)), 1);
var severe = extreme.where(vci_median.gte(10).and(vci_median.lt(20)), 2);
var moderate = severe.where(vci_median.gte(20).and(vci_median.lt(30)), 3);
var light = moderate.where(vci_median.gte(30).gte(vci_median.lt(40)), 4);
var no1 = light.where(vci_median.gte(40).and(vci_median.lt(60)), 5);
var no2 = no1.where(vci_median.gte(60).and(vci_median.lt(80)), 6);
var no3 = no2.where(vci_median.gte(80), 7);
Map.addLayer(moderate.clip(roi), {min: 1, max: 7}, 'drought_map', false);
// VCI时间序列分类
var time_start = '2001', time_end = '2024';
var ndvi2 = ee.ImageCollection("MODIS/061/MOD13A2")
.select(['NDVI'])
.filterDate(time_start, time_end);
var ndvi_min2 = ndvi2.min().multiply(0.0001);
var ndvi_max2 = ndvi2.max().multiply(0.0001);
var vci2 = ndvi2.map(function (img) {
var band = img.multiply(0.0001);
var index = band.expression('((ndvi - min)/(max - min))*100.0', {
'ndvi': band,
'min': ndvi_min2,
'max': ndvi_max2
}).rename('vci');
return index.copyProperties(img, ['system:time_start', 'system:time_end']);
});
// 修正:vci_class 应使用 vci2 而不是 vci_median
var vci_class = vci2.map(function (img) {
var vci_value = img.select('vci');
return img.expression(
'extreme + severe + moderate + light + no1 + no2 + no3',
{
'extreme': vci_value.gte(0).and(vci_value.lt(10)).multiply(1),
'severe': vci_value.gte(10).and(vci_value.lt(20)).multiply(2),
'moderate': vci_value.gte(20).and(vci_value.lt(30)).multiply(3),
'light': vci_value.gte(30).and(vci_value.lt(40)).multiply(4),
'no1': vci_value.gte(40).and(vci_value.lt(60)).multiply(5),
'no2': vci_value.gte(60).and(vci_value.lt(80)).multiply(6),
'no3': vci_value.gte(80).multiply(7)
}
).rename('class');
});
var vci_map = vci_class.mode();
Map.addLayer(vci_map.clip(roi), {
palette: ['black', 'brown', 'red', 'orange', 'yellow', 'lightgreen', 'darkgreen'],
min: 1,
max: 7
}, 'vci_mode', false);
// 导出VCI分类图
Export.image.toDrive({
image: vci_map.clip(roi),
description: 'vci_map',
region: roi,
maxPixels: 1e13,
crs: 'EPSG:4326',
folder: 'drought',
scale: 1000
});
// 计算干旱面积
var drought_area = (ee.Image.pixelArea().divide(1e6)).addBands(vci_map);
print(
ui.Chart.image.byClass(drought_area, 'constant',
roi, ee.Reducer.sum(), 1000, ['nan', 'extreme drought', 'severe drought', 'moderate drought', 'light drought', 'no drought1', 'nodrought2', 'no drought3'])
);
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
- 97.
- 98.
- 99.
- 100.
- 101.
- 102.
- 103.
- 104.
- 105.
- 106.
- 107.
- 108.
- 109.
- 110.
- 111.
- 112.
- 113.
- 114.
- 115.
- 116.