GEE21:基于MODIS数据获取逐年GPP、EVI和FVC数据
逐年GPP、EVI和FVC获取
- 1. 逐年GPP获取
- 2. 逐年EVI获取
- 3.逐年FVC获取
1. 逐年GPP获取
// 设置感兴趣区域
var geometry = table.geometry();
Map.centerObject(geometry, 5);
Map.addLayer(geometry, {color: "black"}, "ROI")
// 加载 MODIS/006/MOD17A2H 数据集
var dataset = ee.ImageCollection("MODIS/006/MOD17A2H").select('Gpp');
var gppVis = {
min: 0,
max: 600,
palette: ['bbe029', '0a9501', '074b03'],
};
Map.addLayer(dataset.filterBounds(geometry), gppVis, 'GPP');
// 定义起始年份和结束年份
var startYear = 2000;
var endYear = 2022;
// 定义一个函数用于按年合成并导出影像
var exportYearlyComposite = function(year) {
year = ee.Number(year);
// 过滤特定年份的影像集合
var yearCollection = dataset.filterBounds(geometry)
.filter(ee.Filter.calendarRange(year, year, 'year'));
// 合成影像
var yearImage = yearCollection.mean().multiply(0.0001).clip(geometry);
// 设置导出参数
var exportParams = {
image: yearImage.toFloat(),
description: 'REG_modis_gpp_yearly_' + year.getInfo(),
folder: 'evi',
region: geometry,
scale: 500,
crs: "EPSG:4326",
maxPixels: 1e13,
};
// 导出影像
Export.image.toDrive(exportParams);
print(exportParams)
print(year)
print(yearCollection)
};
// 遍历每个年份并导出影像
for (var year = startYear; year <= endYear; year++) {
exportYearlyComposite(year);
}
2. 逐年EVI获取
// 设置感兴趣区域
var geometry = table.geometry();
Map.centerObject(geometry, 5);
Map.addLayer(geometry, {color: "black"}, "ROI")
// 加载 MODIS/006/MOD17A2H 数据集
var dataset = ee.ImageCollection("MODIS/061/MOD13A1").select('EVI');
var gppVis = {
min: 0,
max: 600,
palette: ['bbe029', '0a9501', '074b03'],
};
Map.addLayer(dataset.filterBounds(geometry), gppVis, 'EVI');
// 定义起始年份和结束年份
var startYear = 2000;
var endYear = 2022;
// 定义一个函数用于按年合成并导出影像
var exportYearlyComposite = function(year) {
year = ee.Number(year);
// 过滤特定年份的影像集合
var yearCollection = dataset.filterBounds(geometry)
.filter(ee.Filter.calendarRange(year, year, 'year'));
// 合成影像
var yearImage = yearCollection.mean().multiply(0.0001).clip(geometry);
// 设置导出参数
var exportParams = {
image: yearImage.toFloat(),
description: 'REG_modis_evi_yearly_' + year.getInfo(),
folder: 'evi',
region: geometry,
scale: 500,
crs: "EPSG:4326",
maxPixels: 1e13,
};
// 导出影像
Export.image.toDrive(exportParams);
print(exportParams)
print(year)
print(yearCollection)
};
// 遍历每个年份并导出影像
for (var year = startYear; year <= endYear; year++) {
exportYearlyComposite(year);
}
3.逐年FVC获取
植被覆盖度作为全球气候变化模型和描述生态系统的重要参数,通过有效获取植被进行光合作用面积的大小以及植被生长的茂盛程度,主要表现为地表植被的覆盖状态。植被覆盖度的计算采用目前较为成熟的算法—像元二分模型,将所有像元视为混合像元,分为土壤和植被两个部分,植被覆盖度计算方法如下:
式中,FVC 为像元的植被覆盖度;EVIv 为研究区所有像元中 EVI 最大值,即纯植被像元的 EVI 值;EVIs 为研究区所有像元中 EVI 最小值,即裸土的 EVI 值。考虑遥感影像受大气环境、地表粗糙度和植被类型等因素的影响,本研究通过对研究区范围内像元的 EVI 进行统计,截取置信区间累计频率在 5%和 95%处对应的 EVI 值分别为 EVI 的最小值与最大值,对应上式中的 EVIs 和 EVIv,从而得到研究区植被覆盖度分布数据。
var roi = table.geometry();
Map.addLayer(roi, {'color':'blue'}, 'StudyArea');
Map.centerObject(roi, 6);
// 像元二分模型计算计算FVC
function calFVC(BestVI,region,scale){
var num = BestVI.reduceRegion({
reducer:ee.Reducer.percentile([5,95]),
geometry:region,
scale:scale,
maxPixels:1e13
});
var min = ee.Number(num.get("NDVI_p5"));
var max = ee.Number(num.get("NDVI_p95"));
var greaterPart = BestVI.gt(max);
var lessPart = BestVI.lt(min);
var middlePart =ee.Image(1).subtract(greaterPart).subtract(lessPart);
var tempf1=BestVI.subtract(min).divide(max.subtract(min));
var FVC=ee.Image(1).multiply(greaterPart).add(ee.Image(0).multiply(lessPart))
.add(tempf1.multiply(middlePart));
return FVC.rename('FVC');
}
var start_year = 2000
var end_year = 2022
for(var i = start_year; i <= end_year; i++){
var start_date = (i) + '-05-01';
var end_date = (i + 1) + '-10-01';
print("Time frame: ", start_date + "---" + end_date)
// get image collection
var dataset = ee.ImageCollection("MODIS/061/MOD13A1")
.filterBounds(roi)
.filterDate(start_date, end_date)
.select('EVI');
var bestEVI = dataset.mean().clip(roi).multiply(0.0001);
print(bestEVI,i+'_year_'+i+'_bestEVI_Year_mean')
var EVIVis = {
min: -0.2,
max: 0.5,
palette: ['bbe029', '0a9501', '074b03'],
};
Map.addLayer(bestEVI, EVIVis, 'EVI'+i);
//calculate the 5% and 95% num of the image
var num =bestEVI.reduceRegion({
reducer:ee.Reducer.percentile([5,95]),
geometry:roi,
scale:500,
maxPixels:1e13
});
print("num",num);
var min = ee.Number(num.get("EVI_p5"));
var max = ee.Number(num.get("EVI_p95"));
print("min",min);
print("max",max)
//quantile and combine
var greaterPart = bestEVI.gt(max);
var lessPart = bestEVI.lt(min);
var middlePart =ee.Image(1).subtract(greaterPart).subtract(lessPart); // get the middle part
//var mask=bestNDVI.gt(mim).add(bestNDVI.lt(min));
//var middlePart=bestNDVI.updateMask(mask);
//calculate FVC
var tempf1=bestEVI.subtract(min).divide(max.subtract(min));
//ee.Image(constant): creat a constatnt image
var FVC=ee.Image(1).multiply(greaterPart)
.add(ee.Image(0).multiply(lessPart))
.add(tempf1.multiply(middlePart));
Map.addLayer(FVC,{},"FVC" + i);
// export to drive
Export.image.toDrive(
{
image: FVC.toFloat(),
description: 'modis_fvc_yearly_' + i,
folder: 'fvc',
region: roi,
scale: 500,
crs: "EPSG:4326",
maxPixels: 1e13,
})
}