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

时间:2019-05-25 15:05:18

标签: google-app-engine google-earth-engine

我需要汇总GPM集合每天48个半小时图像的总和,以获取带有“ precipitationCal”乐队的图像集合和每日图像

我试图填充并迭代一个空的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))

1 个答案:

答案 0 :(得分:1)

请尝试使用我的软件包pkg_trend。其中的aggregate_prob功能与R language中的aggregate一样工作。

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

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 pkg_trend = require('users/kongdd/public:Math/pkg_trend.js');
var imgcol_daily = pkg_trend.aggregate_prop(imgcol, "date_daily", 'sum');
print(imgcol_daily);

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

GEE链接为https://code.earthengine.google.com/2e04ad4a4bee6789af23bfac42f63025