var geometry = ee.FeatureCollection('projects/ee/assets/HLJ')
Map.addLayer(geometry)
var collection = ee.ImageCollection("MODIS/006/MOD17A2H")
.filterDate('2000-01-01', '2021-12-31')
.select("Gpp")
.map(function(image){
return image.multiply(0.0001).set(image.toDictionary(image.propertyNames()))
});
var years = ee.List.sequence(2000, 2021);
var collectYear = ee.ImageCollection(years
.map(function(y) {
var start = ee.Date.fromYMD(y, 1, 1);
var end = start.advance(12, 'month');
return collection.filterDate(start, end).reduce(ee.Reducer.mean()).float().set('system:time_start',y).set('year',y);
}));
print(collectYear)
var Yearly_chart = ui.Chart.image.series({
imageCollection: collectYear.select('Gpp_mean'),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 500,
xProperty: 'year',
}).setOptions({
interpolateNulls: true,
lineWidth: 2,
title: 'GPP Yearly Seires',
vAxis: {title: 'GPP'},
hAxis: {title: 'Date'},
trendlines: { 0: {title: 'GPP_trend',type:'linear', showR2: true, color:'red', visibleInLegend: true}}
});
print(Yearly_chart);
结果如下图: