ImageCollection 图表

ui.Chart.image 模块包含一组函数,用于根据 ImageCollection 中图片的时空压缩结果渲染图表。所选函数决定了图表中数据的排列方式,即决定了 x 轴和 y 轴值以及系列的定义。请参考以下函数说明和示例,确定最适合您的用途的函数。

图表函数

请将以下图表作为直观指南,了解每个函数如何在图表中排列时空图像集合缩减结果;即,哪些元素定义了 x 值、y 值和系列。请注意,ui.Chart.image.doySeries* 函数接受两个 reducer:一个用于地区减少 (regionReducer),另一个用于年内同一日期减少 (yearReducer)。以下部分中的示例使用 ee.Reducer.mean() 作为这两个参数的参数。

ui.Chart.image.series

图片日期会根据 system:time_start 属性沿 x 轴绘制。系列由图像波段定义。Y 轴值是单个区域按日期减少的图片数。

ui.Chart.image.seriesByRegion

图片日期会根据 system:time_start 属性沿 x 轴绘制。系列是按地区定义的。Y 轴值是单个图像波段的图片减少情况(按日期)。

ui.Chart.image.doySeries

图片年份日数会根据 system:time_start 属性沿 x 轴绘制。系列由图像波段定义。Y 轴值是给定区域内图片像素减少的幅度,按年份日期分组。

ui.Chart.image.doySeriesByYear

图片的年份日数会根据 system:time_start 属性沿 x 轴绘制。系列由 ImageCollection 中显示的年份定义。Y 轴值是所选图像波段在给定区域内像素减少量,按年份日期分组。

ui.Chart.image.doySeriesByRegion

图片的年份日数会根据 system:time_start 属性沿 x 轴绘制。系列是按地区定义的。Y 轴值是所选图像波段在给定区域内像素减少量,按年份日期分组。

示例数据

以下示例依赖于 ImageCollection,它是基于 MODIS 的 NDVI 和 EVI 的时间序列。对为演示目的而设计的 FeatureCollection 中的地图项定义的生态区执行区域缩减(了解其制作方式)。

ui.Chart.image.series

使用 ui.Chart.image.series 可显示给定区域的图像时间序列;每个图像波段都显示为一个独特的序列。它有助于比较单个图像波段的时间序列。此处绘制了包含代表 NDVI 和 EVI 植被指数的波段的 MODIS 图像集。x 轴显示了每项图像观测的日期,而与森林生态区域相交的像素的平均减少量定义了 y 轴。

// Import the example feature collection and subset the forest feature.
var forest = ee.FeatureCollection('projects/google/charts_feature_example')
                 .filter(ee.Filter.eq('label', 'Forest'));

// Load MODIS vegetation indices data and subset a decade of images.
var vegIndices = ee.ImageCollection('MODIS/061/MOD13A1')
                     .filter(ee.Filter.date('2010-01-01', '2020-01-01'))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .series({
          imageCollection: vegIndices,
          region: forest,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'system:time_start'
        })
        .setSeriesNames(['EVI', 'NDVI'])
        .setOptions({
          title: 'Average Vegetation Index Value by Date for Forest',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Vegetation index (x1e4)',
            titleTextStyle: {italic: false, bold: true}
          },
          lineWidth: 5,
          colors: ['e37d05', '1d6b99'],
          curveType: 'function'
        });
print(chart);

ui.Chart.image.seriesByRegion

使用 ui.Chart.image.seriesByRegion 可显示多个区域的单个图像波段时间序列;每个区域都显示为一个单独的时间序列。这对于比较多个区域中单个频段的时间序列非常有用。此处,为三个生态区绘制了代表 NDVI 时间序列的 MODIS 图像集合。x 轴包含每项图像观测的日期,而与森林、沙漠和草原生态区域相交的像素的平均减少量定义了 y 轴系列。

// Import the example feature collection.
var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example');

// Load MODIS vegetation indices data and subset a decade of images.
var vegIndices = ee.ImageCollection('MODIS/061/MOD13A1')
                     .filter(ee.Filter.date('2010-01-01', '2020-01-01'))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .seriesByRegion({
          imageCollection: vegIndices,
          band: 'NDVI',
          regions: ecoregions,
          reducer: ee.Reducer.mean(),
          scale: 500,
          seriesProperty: 'label',
          xProperty: 'system:time_start'
        })
        .setOptions({
          title: 'Average NDVI Value by Date',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'NDVI (x1e4)',
            titleTextStyle: {italic: false, bold: true}
          },
          lineWidth: 5,
          colors: ['f0af07', '0f8755', '76b349'],
        });
print(chart);

ui.Chart.image.doySeries

使用 ui.Chart.image.doySeries 可显示给定区域的年份日期时间序列;每个图像波段都显示为一个独特的序列。这对于减少在多年中同一天发生的观测非常有用,例如,比较 MODIS 的平均年 NDVI 和 EVI 剖面,如本例所示。

// Import the example feature collection and subset the grassland feature.
var grassland = ee.FeatureCollection('projects/google/charts_feature_example')
                    .filter(ee.Filter.eq('label', 'Grassland'));

// Load MODIS vegetation indices data and subset a decade of images.
var vegIndices = ee.ImageCollection('MODIS/061/MOD13A1')
                     .filter(ee.Filter.date('2010-01-01', '2020-01-01'))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .doySeries({
          imageCollection: vegIndices,
          region: grassland,
          regionReducer: ee.Reducer.mean(),
          scale: 500,
          yearReducer: ee.Reducer.mean(),
          startDay: 1,
          endDay: 365
        })
        .setSeriesNames(['EVI', 'NDVI'])
        .setOptions({
          title: 'Average Vegetation Index Value by Day of Year for Grassland',
          hAxis: {
            title: 'Day of year',
            titleTextStyle: {italic: false, bold: true}
          },
          vAxis: {
            title: 'Vegetation index (x1e4)',
            titleTextStyle: {italic: false, bold: true}
          },
          lineWidth: 5,
          colors: ['e37d05', '1d6b99'],
        });
print(chart);

ui.Chart.image.doySeriesByYear

使用 ui.Chart.image.doySeriesByYear 可显示给定区域和图像波段的年份时间序列,其中图像集合中的每个不同年份都显示为一个独特的序列。这对于比较不同年份的年份时间序列非常有用。例如,在此示例中,系统绘制了 2012 年和 2019 年草原生态区的 MODIS 派生 NDVI 年份剖面,方便用户对比分析年同比变化。

// Import the example feature collection and subset the grassland feature.
var grassland = ee.FeatureCollection('projects/google/charts_feature_example')
                    .filter(ee.Filter.eq('label', 'Grassland'));

// Load MODIS vegetation indices data and subset years 2012 and 2019.
var vegIndices = ee.ImageCollection('MODIS/061/MOD13A1')
                     .filter(ee.Filter.or(
                         ee.Filter.date('2012-01-01', '2013-01-01'),
                         ee.Filter.date('2019-01-01', '2020-01-01')))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .doySeriesByYear({
                  imageCollection: vegIndices,
                  bandName: 'NDVI',
                  region: grassland,
                  regionReducer: ee.Reducer.mean(),
                  scale: 500,
                  sameDayReducer: ee.Reducer.mean(),
                  startDay: 1,
                  endDay: 365
                })
                .setOptions({
                  title: 'Average NDVI Value by Day of Year for Grassland',
                  hAxis: {
                    title: 'Day of year',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  vAxis: {
                    title: 'NDVI (x1e4)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  lineWidth: 5,
                  colors: ['39a8a7', '9c4f97'],
                });
print(chart);

ui.Chart.image.doySeriesByRegion

使用 ui.Chart.image.doySeriesByRegion 可为多个区域显示单个图像带的日期时间序列,其中每个不同的区域都显示为一个独特的时间序列。这对于比较不同地区的单波段年度时间序列非常有用。例如,在此示例中,系统绘制了森林、沙漠和草原生态区的 MODIS 派生 NDVI 年份剖面,以便用户方便地按区域比较 NDVI 响应。请注意,同一年份内发生在同一天内的观测值会减去其平均值。

// Import the example feature collection.
var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example');

// Load MODIS vegetation indices data and subset a decade of images.
var vegIndices = ee.ImageCollection('MODIS/061/MOD13A1')
                     .filter(ee.Filter.date('2010-01-01', '2020-01-01'))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .doySeriesByRegion({
                  imageCollection: vegIndices,
                  bandName: 'NDVI',
                  regions: ecoregions,
                  regionReducer: ee.Reducer.mean(),
                  scale: 500,
                  yearReducer: ee.Reducer.mean(),
                  seriesProperty: 'label',
                  startDay: 1,
                  endDay: 365
                })
                .setOptions({
                  title: 'Average NDVI Value by Day of Year',
                  hAxis: {
                    title: 'Day of year',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  vAxis: {
                    title: 'NDVI (x1e4)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  lineWidth: 5,
                  colors: ['f0af07', '0f8755', '76b349'],
                });
print(chart);