基于GEE(Google earth engine)的 GIMMS NDVI月合成

本文探讨了如何在Google Earth Engine中准确处理GIMMS数据,避免月度合成中28天尺度的问题,通过代码实现长时间序列NDVI数据的月度合成,展示了如何利用GIMMS的长时段优势并提供解决方案。
摘要由CSDN通过智能技术生成

这里写自定义目录标题

动机

项目需要用到长时间序列的NDVI数据,一般人常用到的是MODIS的月合成产品,而忽略了GIMMS,是因为其空间分辨率低;但是其依然具有其他产品无法比拟的优势,那就是时间序列长。并且SPOT的时间序列也要比MODIS早。参考链接与代码链接在文末尾标注可以查看。

代码

在我看到过一个帖子,也很好,但是他月合成的方式,有点问题,直接把每个月都算成28天去合成。在月尺度和28天尺度上最大值合成。虽然结果差不多吧,但是我心里上还是不能接受;一直使用代码解决问题的思想,让我坚信能用月合成,而不是28天,所以我简单搜了下,找到的解决方案,希望给后面遇到同样苦难的同学提供解决思路。
废话不多说,直接贴代码。



// //显示边界 
// 这里构建空的Image,然后通过palette设置边界颜色
var empty = ee.Image().toByte();

var outline = empty.paint({
  featureCollection:MBR_HB,  // 筛选的colletion
  color:0, //颜色透明
  width:1  //边界宽度
});
// Map.addLayer(Hulunbuir, {palette: "ff0000"},'Hulunbuir');

Map.addLayer(MBR_HB, {palette: "ff0000"},'MBR_HB');

print(imageCollection);

var years = ee.List.sequence(1981, 2013);
var months = ee.List.sequence(1, 12);

var map_m = function(i) {
  i = ee.Number(i);
  var filtered_col = years.map(function(j) {
    var filtered = imageCollection
        .filter(ee.Filter.calendarRange(i, i, 'month'))
        .filter(ee.Filter.calendarRange(j, j, 'year'))
        .select('ndvi')
        .max();
    return filtered;
  });
  return filtered_col;
};

var img_col = ee.ImageCollection(months.map(map_m).flatten());

print(img_col);

// var checkImage = ee.Image(img_col.filter(ee.Filter.eq('system:index', '10')).first());

// print(checkImage);

// Map.addLayer(checkImage, {min:-1,max:1}, 'test');


// var indexs = ee.List.sequence(0, 395);
for(var i=0;i<=3;i++){
  var checkImage = ee.Image(img_col.filter(ee.Filter.eq('system:index', String(i))).first()).clip(MBR_HB);
  print(checkImage);
  
  
  Map.addLayer(checkImage, {min:-1,max:1},"ndvi_index_"+i);

  Export.image.toDrive({
      image: checkImage,
      description: "index_"+i,
      crs: "EPSG:4326",
      // scale: 1000,
      region: MBR_HB,
      maxPixels: 1e13,
      folder: 'Hulunbuir'
      
    });
}

参考的帖子
https://gis.stackexchange.com/questions/279622/writing-code-for-monthly-ndvi-medians-in-google-earth-engine
我的GEE分享链接
https://code.earthengine.google.com/?scriptPath=users%2F1363989042%2FCannabis_Sentinel2%3ANDVI%2FGIMMS_Download

  • 3
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
以下是使用Google Earth Engine获取逐日NDVI的代码示例: ```javascript // 设置ROI var roi = ee.Geometry.Rectangle([xmin, ymin, xmax, ymax]); // 设置起始和结束日期 var startDate = ee.Date('2019-01-01'); var endDate = ee.Date('2019-12-31'); // 加载MODIS数据 var modis = ee.ImageCollection('MODIS/006/MOD13A1') .filterBounds(roi) .filterDate(startDate, endDate) .select('NDVI'); // 定义函数计算每个图像的年份和日数 var addDate = function(image) { var doy = image.date().getRelative('day', 'year'); return image.addBands(doy).addBands(image.date().get('year')); }; // 对图像集应用函数 var modisWithDate = modis.map(addDate); // 定义函数计算每个年份和日数的平均NDVI值 var reduceDaily = function(imageCollection, year, doy) { var filtered = imageCollection.filter(ee.Filter.calendarRange(year, year, 'year')) .filter(ee.Filter.calendarRange(doy, doy, 'day_of_year')); return filtered.mean().set('year', year).set('doy', doy); }; // 创建一个二维数组,其中第一维表示年份,第二维表示一年中的日数 var years = ee.List.sequence(startDate.get('year'), endDate.get('year')); var days = ee.List.sequence(1, 365); // 对所有年份和日数应用reduceDaily函数 var dailyNDVI = ee.ImageCollection.fromImages(years.map(function(y){ return days.map(function(d){ return reduceDaily(modisWithDate, y, d); }); }).flatten()); // 打印输出结果 print(dailyNDVI); ``` 在上述代码中,首先定义了一个感兴趣区域(ROI),然后加载了2000年至今的MODIS NDVI数据,并对其进行了筛选。接着定义了两个函数,一个函数用于向每个图像添加年份和日数作为带宽,另一个函数用于计算每个年份和日数的平均NDVI值。最后,将所有年份和日数应用到reduceDaily函数中,生成逐日的NDVI值。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值