在 GEE 中将每小时 GPM 数据汇总为每日数据

Aggregate GPM hourly data to daily in GEE

我需要汇总一个 GPM 集合每天 48 张半小时图像的总和,得到带“precipitationCal”的 imageCollection 和每日图像

我尝试填充和迭代一个空的 featureCollection,但我得到一个没有图像的空集合

    var dataset = ee.ImageCollection('NASA/GPM_L3/IMERG_V05')
    var startdate = ee.Date.fromYMD(2014,3,1)
    var enddate = ee.Date.fromYMD(2014,4,1)
    var precipitation = dataset.filter(ee.Filter.date(startdate,enddate)).select('precipitationCal')
    print(precipitation)
    
    var difdate = enddate.difference(startdate, 'day')
    
    // Time lapse
    var lapse = ee.List.sequence(0, difdate.subtract(1))
    var startdate = ee.Date('2014-01-01')
    var listdates = lapse.map(function(day){
      return startdate.advance(day, 'day')
    })
    
    var pts = ee.FeatureCollection(ee.List([]))
    var newft = ee.FeatureCollection(listdates.iterate(function(img, ft) {
      // Cast
      ft = ee.FeatureCollection(ft)
      var day = ee.Date(img)
      // Filter the collection in one day
      var day_collection = precipitation.filterDate(day, day.advance(1, 'day'))
      // Get the sum of all 24 images into one Image
      var sum = ee.Image(day_collection.sum())
      // Return the FeatureCollection with the new properties set
      return sum
    }, listdates))

请试一下我的包裹pkg_trend. aggregate_prob function in it, works just like aggregate in R language

var imgcol_all = ee.ImageCollection('NASA/GPM_L3/IMERG_V06');

function add_date(img){
    var date  = ee.Date(img.get('system:time_start'));
    var date_daily = date.format('YYYY-MM-dd');
    return img.set('date_daily', date_daily);
}

var startdate = ee.Date.fromYMD(2014,3,1);
var enddate   = ee.Date.fromYMD(2014,4,1);
var imgcol = imgcol_all
    .filter(ee.Filter.date(startdate,enddate)).select('precipitationCal')
    .map(add_date);
// imgcol = pkg_trend.imgcol_addSeasonProb(imgcol); 
print(imgcol.limit(3), imgcol.size());

var pkgs = require('users/kongdd/pkgs:pkgs.js');
var imgcol_daily = pkgs.aggregate_prop(imgcol, "date_daily", 'sum');
print(imgcol_daily);

Map.addLayer(imgcol_daily, {}, 'precp daily');

GEE link 是 https://code.earthengine.google.com/3d8c7e68e0a7a16554ff8081880bfdad

根据GEE GPM page,本产品是半小时降水率。因此,要使用上面的代码获得每日总和,您应该将集合中的每张图像除以 2。