我想解决在尝试使用 Google Earth Engine 将 GLDAS 月降水量输出到 CSV 时出现的 "system:time_start" 错误

I want to solve the "system:time_start" error when trying to output GLDAS monthly precipitation to CSV using Google Earth Engine

我正在使用 GoogleEarthEngine 查看湄公河流域的降水数据。 GLDAS 数据每天每三个小时设置一次。我的目标是通过按月累加数据来提取 2000 年到 2020 年的 GLDAS 数据。

我想使用 Google Earth Engine 提取 GLDAS 中的月总降水量,但由于错误无法提取 CSV

Image.date: Image '120' has a 'system:time_start' property which is not a number: 2010-01-01T00:00:00

我想我可以通过转换“system:time_start”来提取CSV,我应该如何更改它?

var studyArea = ee.Geometry.Rectangle(102, 8.5, 107, 15);
Map.centerObject(mekong, 9);

// 解析対象年
var years = ee.List.sequence(2000, 2019);
var months = ee.List.sequence(1, 12);

var early = ('2010-01-01');
var late =  ('2011-01-01');

// MOD11A1の取り出し
var image = ee.ImageCollection('NASA/GLDAS/V021/NOAH/G025/T3H')
  .filterDate(early, late).filterBounds(mekong);
//print(image);

// mmに変換してmodLSTcに保存
var gldas_precipitation = image.select('Rainf_f_tavg');
var gldas_precipitation_mm = gldas_precipitation.map(function(img)
  {return img.multiply(10080.0).copyProperties(img, ['system:time_start'])});

// 変数gldas_precipitation_mm_monthの中に月単位のメジアンデータを保存  ////////////////////////////////////////////
var gldas_precipitation_mm_month = ee.ImageCollection.fromImages(
  years.map(function(y) {
    return months.map(function(m) {
      var monthly = gldas_precipitation_mm.filter(ee.Filter.calendarRange(y, y, 'year'))
        .filter(ee.Filter.calendarRange(m, m, 'month'))
        .sum()
        .rename('precipitation_mm_month');
    
    return monthly.set('year', y).set('system:time_start', ee.Date.fromYMD(y, 1, 1))
      .set('month', y).set('system:time_start', ee.Date.fromYMD(y, m, 1));
  });
}).flatten());

var gldas_precipitation_mm_month = gldas_precipitation_mm_month.filterBounds(mekong);

// TSLのポリゴン ///////////////////////////////////////////////////////////////////////////////////
var empty = ee.Image().byte();
// Paint all the polygon edges with the same number and width, display
var outline = empty.paint({
  featureCollection: mekong,
  color: 1,
  width: 2
});
Map.addLayer(outline, {palette: 'FF0000'}, 'TSL');

//output_csv_precipitation
//Create variables and extract data
var scale = gldas_precipitation_mm_month.mean().projection().nominalScale().multiply(0.05); print(scale);
var gldas = gldas_precipitation_mm_month.filter(ee.Filter.listContains('system:band_names', gldas_precipitation_mm.mean().bandNames().get(0)));
var ft = ee.FeatureCollection(ee.List([]));

//Function to extract values from image collection based on point file and export as a table 
var fill = function(img, ini) {
var inift = ee.FeatureCollection(ini);
var ft2 = img.reduceRegions(mekong, ee.Reducer.mean(), scale);
var date = img.date().format("YYYY/MM/dd");
var ft3 = ft2.map(function(f){return f.set('month', date)});
return inift.merge(ft3);
};

// Iterates over the ImageCollection
var profile = ee.FeatureCollection(gldas_precipitation_mm_month.iterate(fill, ft));
print(profile,'profile');

属性 system:time_start 的值必须是 数字 (即使它是日期有意义,系统设计没有那样结束)。您必须像

这样更改调用
.set('system:time_start', ee.Date.fromYMD(y, m, 1))

.set('system:time_start', ee.Date.fromYMD(y, m, 1).millis())

在查看时,我发现这里还有其他可能的问题:

    return monthly.set('year', y).set('system:time_start', ee.Date.fromYMD(y, 1, 1))
      .set('month', y).set('system:time_start', ee.Date.fromYMD(y, m, 1));

这是将 month 属性 值设置为 y 变量(而不是 m),并且它设置了两次 system:time_start(因此只有将使用第二个值)。可能这不是你的意思。我没有看你打算用这个集合做什么,所以你必须自己弄清楚这部分。