目录
1 完整代码
2 运行结果
本文所使用的NPP数据集来自MODIS MOD17A3HGF产品,时间跨度为2001-2024年,空间分辨率500m,时间分辨率为年。
1 完整代码
var geometry = table;
Map.centerObject(geometry, 6);var dataset = ee.ImageCollection("MODIS/061/MOD17A3HGF").filterBounds(geometry).select('Npp');var nppList = [];for (var i = 2001; i <= 2024; i++) {var data_collection = dataset.filterDate(i + '-01-01', i + '-12-31');var YR_collection = data_collection.mean().multiply(0.1).clip(geometry);var nppMean = YR_collection.reduceRegion({reducer: ee.Reducer.mean(),geometry: geometry,scale: 500,maxPixels: 1e13}).get('Npp');nppList.push(ee.Feature(null, {'Year': i, 'Mean_NPP': nppMean}));Export.image.toDrive({image: YR_collection,description: i + "_MOD17A3HGF_NPP",fileNamePrefix: i + "_MOD17A3HGF_NPP",scale: 500,region: geometry,crs: "EPSG:4326",maxPixels: 1e13,folder: 'MOD17A3HGF'});
}var nppTable = ee.FeatureCollection(nppList);Export.table.toDrive({collection: nppTable,description: 'Annual_NPP_2001_2024',fileFormat: 'CSV',folder: 'MOD17A3HGF'
});var chart = ui.Chart.feature.byFeature(nppTable, 'Year', 'Mean_NPP').setChartType('LineChart').setOptions({title: 'Annual Mean NPP (2001-2024)',hAxis: { title: 'Year', format: '####', viewWindow: { min: 2001, max: 2024 }},vAxis: { title: 'Mean NPP (gC/m²/yr)' },lineWidth: 1,pointSize: 2,colors: ['black'],curveType: 'function',legend: { position: 'none' }});print(chart);
2 运行结果


