目录
1 数据介绍
1.1 MODIS/061/MYD13Q1产品数据
1.2 MODIS/061/MOD09GA产品数据
2 完整代码
var geometry = roi;
Map.centerObject(geometry, 6);
//MODIS/061/MYD13Q1产品数据
//选取影像集
var collection = ee.ImageCollection("MODIS/006/MYD13Q1")
.filterDate('2020-01-01', '2020-12-31');
print(collection); //方便看看这一年有多少副影像
//选择波段 NDVI
var ndvi = collection.select("NDVI");
var multiply = function(image) {
//multiply image
var img = image.multiply(0.0001);
return img.set('system:time_start', image.get('system:time_start'));
};
ndvi = ndvi.map(multiply);
//设置调色板并展示影像
var colorizedVis = {
min: 0.0,
max: 1.0,
palette: [
'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
'66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
'012E01', '011D01', '011301'
],
};
Map.addLayer(ndvi.median().clip(geometry), colorizedVis, 'NDVI');
//绘制NDVI年间变化折线图
print(ui.Chart.image.series(ndvi, geometry, ee.Reducer.mean(), 250));
//MODIS/061/MOD09GA产品数据
//加载影像
var dailyNDVI = ee.ImageCollection("MODIS/MOD09GA_006_NDVI")
.filterDate('2020-01-01', '2020-12-31')
.select('NDVI');
print(dailyNDVI);
//查看一年有多少副影像
Map.addLayer(dailyNDVI.mean().clip(geometry), colorizedVis, 'dailyNDVI');
//这里统计的时候像素大小选择为1000,大家可以自行调整
print(ui.Chart.image.series(dailyNDVI, geometry, ee.Reducer.mean(), 1000));
//先筛选我们研究的时间范围
var years = ee.List.sequence(2020, 2020);
var months = ee.List.sequence(1, 12);
//将逐日数据生成月平均数据
var monthlymeanNDVI = ee.ImageCollection.fromImages(
years.map(function (y) {
return months.map(function(m) {
return dailyNDVI
.filter(ee.Filter.calendarRange(y, y, 'year'))
.filter(ee.Filter.calendarRange(m, m, 'month'))
.mean()
.set('year', y)
.set('month', m)
.set('system:time_start', ee.Date.fromYMD(y, m, 1));
});
}).flatten()
);
//Create and print charts.
print(ui.Chart.image.series(monthlymeanNDVI, geometry, ee.Reducer.mean(), 1000));