使用Google Earth Engine将每日数据减少到每月

时间:2018-08-06 15:03:29

标签: javascript time-series reduce google-earth-engine

我正在使用Google Earth Engine查看印度尼西亚不同省份的降水数据(GPMCHIRPS)。 GPM每天(每30分钟),CHIRPS每天。我只对获取每月价值感兴趣。与herehere不同,我对获取多个年度的月度值不感兴趣,而只是对每个月的平均值并建立时间序列感兴趣。

Here我找到了一种创建包含每个月平均值的值列表的方法。

编辑:感谢尼古拉斯·克林顿(Nicholas Clinton)的answer,我设法使它正常工作:

var fc = ee.FeatureCollection('ft:1J2EbxO3zzCLggEYc57Q4mzItFFaaPCAHqe1CBA4u') // Containing multiple polygons
    .filter(ee.Filter.eq('name', 'bangka')); // Here I select my ROI

Map.addLayer(fc, {}, 'area');
Map.centerObject(fc, 7);

var aggregate_array = fc.aggregate_array('name');
print('Name of area: ', aggregate_array, 'Selected data in FeatureCollection:', fc);

var month_mean = ee.List.sequence(0, 16*12).map(function(n) { // .sequence: number of years from starting year to present
  var start = ee.Date('2002-01-01').advance(n, 'month'); // Starting date
  var end = start.advance(1, 'month'); // Step by each iteration

  return ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY")
        .filterDate(start, end)
        .mean()
        .set('system:time_start', start.millis());
});
print(month_mean); 

var collection = ee.ImageCollection(month_mean);

print(collection);

// Plotting

var area_name = fc.aggregate_array('name').getInfo();
var title = 'CHIRPS [mm/hr] for ' + area_name;

var TimeSeries = ui.Chart.image.seriesByRegion({
    imageCollection: collection,
    regions: fc,
    reducer: ee.Reducer.mean(),
    scale: 5000,
    xProperty: 'system:time_start',
    seriesProperty: 'label'
  }).setChartType('ScatterChart')
    .setOptions({
      title: title,
      vAxis: {title: '[mm/hr]'},
      lineWidth: 1,
      pointSize: 1,
    });

print('TimeSeries of selected area:', TimeSeries);

2 个答案:

答案 0 :(得分:1)

未经测试,但应类似以下内容(或设置其他date属性):

return ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY")
      .filterDate(start, end)
      .sum()
      .set('system:time_start', start.millis());

答案 1 :(得分:1)

pkg_trend中的def rad2slice(rad): return int((4 * rad / np.pi + .5) % 8) # Quick test: In [22]: [rad2slice(i*np.pi/4) for i in range(8)] Out[22]: [0, 1, 2, 3, 4, 5, 6, 7] 函数,就像R language中的aggregate_prob一样工作。

aggregate

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