ui.Chart.image
模組包含一組函式,可根據 ImageCollection
內圖像的時空縮減結果,算繪圖表。函式選擇會決定圖表中資料的排列方式,也就是定義 x 軸和 y 軸值,以及定義資料列。請參考下列函式說明和範例,判斷哪個函式最適合您的用途。
圖表函式
請參考下列圖表,瞭解各函式如何在圖表中排列時空影像集合縮減結果,也就是哪些元素定義 x 值、y 值和序列。請注意,ui.Chart.image.doySeries*
函式會採用兩個縮減器:一個用於區域縮減 (regionReducer
),另一個用於一年內重疊的日期縮減 (yearReducer
)。下列各節的範例會使用 ee.Reducer.mean()
做為這兩個參數的引數。
圖片日期會根據 system:time_start
屬性沿著 X 軸繪製。系列是由影像頻帶定義。Y 軸值是單一區域的圖片減少數量,以日期為單位。
圖片日期會根據 system:time_start
屬性沿著 X 軸繪製。系列叢書是由區域定義。Y 軸值是單一圖像頻帶的圖像減少量,以日期為單位。
圖片年內天數會根據 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
顯示特定區域的圖像時間序列;每個圖像頻帶會以獨特的序列呈現。這對於比較個別影像頻帶的時間序列很有幫助。這裡繪製了 MODIS 圖像集合,其中的波段代表 NDVI 和 EVI 植被指數。每張圖片觀察日期會沿著 x 軸顯示,而與森林生態區交會的像素平均減少量則會定義 y 軸。
程式碼編輯器 (JavaScript)
// 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 軸系列。
程式碼編輯器 (JavaScript)
// 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 剖面,如本範例所示。
程式碼編輯器 (JavaScript)
// 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 年度剖面圖繪製成圖,方便您解讀年度間的差異。
程式碼編輯器 (JavaScript)
// 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 回應。請注意,發生在同一年份同一天的內部觀察值會經過平均值減去。
程式碼編輯器 (JavaScript)
// 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);