生成图表时出错:没有要素包含“ system:time_start”的非空值。谷歌地球引擎

时间:2018-07-26 15:41:26

标签: charts error-handling time-series timeserieschart google-earth-engine

我使用的是Google Earth引擎,并且使用了我在网上找到的函数(单击here)(称为temporalCollection)来计算一年中的每月平均值。然后,我将它们显示在地图上,但也希望为其绘制图表。参见下面的代码。

var BIOT = ee.Feature(  // BIOT
ee.Geometry.Rectangle(70.7, -4.7, 72.9, -7.7), {label: 'BIOT'});

var sst = ee.ImageCollection('NASA/OCEANDATA/MODIS-Aqua/L3SMI').select('sst')

var sstMonthly = temporalCollection(sst, ee.Date('2013-01-01'), 12, 1, 
'month');
print('sstMonthly', sstMonthly)

var check = ee.Image(sstMonthly.first());
Map.addLayer(check, {bands: 'sst_mean', min: 0, max: 40, 
'palette':"0000ff,32cd32,ffff00,ff8c00,ff0000"}, 'check')

print(ui.Chart.image.series(sstMonthly, BIOT, ee.Reducer.mean(), 500));

但是,图表出现错误。所有其他方面似乎运行良好。

Error generating chart: No features contain non-null values of 
"system:time_start".

我不太确定这个错误是什么,或者我错过了什么。我刚刚遵循了教程中的基本代码。我是GEE的新手,那里没有太多的研讨会或论坛,非常感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

该错误表示:图像集中(sstMonthly)中的每个图像都没有system:time_start属性,或者此属性的值为null。默认情况下,序列图需要此属性才能知道每个图像在序列图中的位置。

关于您提供的temporalCollection函数,此函数创建的每个图像都不具有system:time_start属性。这很自然,因为默认情况下,通过缩小图像集创建的任何图像都不会具有system:time_start(因为GEE不知道应该分配什么时间)。

有多种方法可以解决此问题,具体取决于要在序列图的水平轴上显示的值。

如果您只想显示该月拍摄的第一张图像的日期,只需在temporalCollection功能代码的末尾添加1行:

    return collection.filterDate(startDate, endDate)
      .reduce(ee.Reducer.mean().combine({
        reducer2: ee.Reducer.minMax(),
        sharedInputs: true
      }))
      .set('system:time_start', startDate.millis());

这会将缩小图像的system:time_start属性设置为与startDate相同的值。您的序列表现在应该可以正常工作。