Google Earth Engine 制图的问题

The trouble with Charting with Google Earth Engine

在Google Earth Engine中,我想从Sentinel 2卫星不同日期的几张图像中获取NDVI指数,然后我将根据该指数估计其他参数。为此,我需要将生成的 NDVI 图像转换为图像集。但是要绘制图表,它会出现以下错误:

生成图表时出错:没有要素包含“system:time_start”的非空值。

似乎在转换为合集图像时,图像的时间信息丢失了。遇到这种情况,我该如何解决?

Link 到代码:https://code.earthengine.google.com/47cd9e7f65b143242ebb238d136bf760

代码:

var sentinel1 = ee.Image('COPERNICUS/S2_SR/20181214T072311_20181214T072733_T39SVV');
var sentinel2 = ee.Image('COPERNICUS/S2_SR/20181219T072319_20181219T072610_T39SVV');
var sentinel3 = ee.Image('COPERNICUS/S2_SR/20181224T072311_20181224T072313_T39SVV');

var ndvi1 = sentinel1.normalizedDifference(['B8','B4']);
var ndvi2 = sentinel2.normalizedDifference(['B8','B4']);
var ndvi3 = sentinel3.normalizedDifference(['B8','B4']);

var NDVI_COL = ee.ImageCollection.fromImages([ndvi1, ndvi2, ndvi3]);

var chart = ui.Chart.image.series(
NDVI_COL, geometry, ee.Reducer.mean(),10,'system:time_start');
print(chart);

尝试this code

制作所选图像的集合,然后绘图

var sentinel1 = ee.Image('COPERNICUS/S2_SR/20181214T072311_20181214T072733_T39SVV');
var sentinel2 = ee.Image('COPERNICUS/S2_SR/20181219T072319_20181219T072610_T39SVV');
var sentinel3 = ee.Image('COPERNICUS/S2_SR/20181224T072311_20181224T072313_T39SVV');

var S2 = ee.ImageCollection([sentinel1, sentinel2, sentinel3])
                .filterBounds(geometry)
                .map(function(image){return image.clip(geometry)});
                
print('collection of Selected Images to plot: ', S2);

var addNDVI = function(image) {
  var ndvi = image.normalizedDifference(['B8', 'B4']).rename('NDVI');
  return image.addBands(ndvi);
};

var S2_NDVI = S2.map(addNDVI);

var NDVI_S2 = ee.ImageCollection(S2_NDVI.select(["NDVI"], ["NDVI"]));

var chart =
    ui.Chart.image
        .seriesByRegion({
          imageCollection: NDVI_S2,
          band: 'NDVI',
          regions: geometry,
          reducer: ee.Reducer.mean(),
          scale: 10,
          xProperty: 'system:time_start'
        })
        .setOptions({
          title: 'Average NDVI Value by Date',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'NDVI',
            titleTextStyle: {italic: false, bold: true}
          },
        });
        
print(chart);