在谷歌地球引擎,我想得到NDVI指数从几个不同日期的哨兵2号卫星的图像,然后我将估计从这个索引的其他参数。为此,我需要将生成的NDVI图像转换为图像集合。但是,要绘制它的图表,它会出现以下错误:
错误生成图表:没有任何功能包含"system:time_start“的非空值。
当转换为集合图像时,图像的时间信息似乎会丢失。在这种情况下,我怎样才能解决它?
链接到代码: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);发布于 2022-01-11 09:56:54
试试这段代码
收集所选图像,然后绘制
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);https://stackoverflow.com/questions/70630581
复制相似问题