Charts 地球发动机;月和年SST

Charts 地球发动机;月和年SST,charts,time-series,average,mean,google-earth-engine,Charts,Time Series,Average,Mean,Google Earth Engine,我正试图绘制一张图表,并从谷歌地球引擎获取数据。我正在地球引擎中使用MODIS Aqua/L3SMI数据 我在内置函数中使用地球引擎来比较每年每天的平均海面温度。但是,它非常繁忙,希望计算每个月的平均值,然后绘制数据集的不同年份。使用这些代码,我可以在数据集中得到多年来每月的平均值 var sst = ee.ImageCollection('NASA/OCEANDATA/MODIS-Aqua/L3SMI').select('sst').filterDate(ee.Date('2013-01-01

我正试图绘制一张图表,并从谷歌地球引擎获取数据。我正在地球引擎中使用MODIS Aqua/L3SMI数据

我在内置函数中使用地球引擎来比较每年每天的平均海面温度。但是,它非常繁忙,希望计算每个月的平均值,然后绘制数据集的不同年份。使用这些代码,我可以在数据集中得到多年来每月的平均值

var sst = ee.ImageCollection('NASA/OCEANDATA/MODIS-Aqua/L3SMI').select('sst').filterDate(ee.Date('2013-01-01'), ee.Date('2017-12-31'))

var byMonth = ee.ImageCollection.fromImages(
  months.map(function (m) {
    return sst.filter(ee.Filter.calendarRange(m, m, 'month'))
                .select(0).mean()
                .set('month', m);
 }));


有没有办法修改这个代码,这样它就可以按月平均每年绘制?因此,您每年在绘图上获得不同的线条,可以用作视觉比较?

要计算每年每个月的平均值,您需要在可能的月份上绘制地图,并按该月份过滤地图中的每个迭代(如下所示)。对于您的具体示例,以下是我将如何做到这一点:

var startDate = ee.Date('2013-01-01'); // set start time for analysis
var endDate = ee.Date('2017-12-31'); // set end time for analysis

// calculate the number of months to process
var nMonths = ee.Number(endDate.difference(startDate,'month')).round();

var point = ee.Geometry.Point([-87.02617187499999, 28.05714582901274]);
var sst = ee.ImageCollection('NASA/OCEANDATA/MODIS-Aqua/L3SMI').select('sst')
            .filterDate(startDate, endDate);

var byMonth = ee.ImageCollection(
  // map over each month
  ee.List.sequence(0,nMonths).map(function (n) {
    // calculate the offset from startDate
    var ini = startDate.advance(n,'month');
    // advance just one month
    var end = ini.advance(1,'month');
    // filter and reduce
    return sst.filterDate(ini,end)
                .select(0).mean()
                .set('system:time_start', ini);
}));

print(byMonth);

Map.addLayer(ee.Image(byMonth.first()),{min: 15, max: 35},'SST');

// plot full time series
print(
  ui.Chart.image.series({
    imageCollection: byMonth,
    region: point,
    reducer: ee.Reducer.mean(),
    scale: 1000
  }).setOptions({title: 'SST over time'})
);

// plot a line for each year in series
print(
  ui.Chart.image.doySeriesByYear({
    imageCollection: byMonth,
    bandName:'sst',
    region: point,
    regionReducer: ee.Reducer.mean(),
    scale: 1000
  }).setOptions({title: 'SST over time'})
);
以下是代码的链接:

我不太确定你在图表中寻找的是什么,所以我提供了两个选项:(1)完整的时间序列图,(2)DOY的图,就像你上面的图一样,每年都有一条线

我希望这有帮助