แผนภูมิรูปภาพ

โมดูล ui.Chart.image มีชุดฟังก์ชันสำหรับการลดImageออบเจ็กต์ตามภูมิภาคและการเรนเดอร์แผนภูมิจากผลลัพธ์ การเลือกฟังก์ชันจะกำหนดการจัดเรียงข้อมูลในแผนภูมิ เช่น การกำหนดค่าแกน x และแกน y รวมถึงการกำหนดชุดข้อมูล ใช้คำอธิบายและตัวอย่างฟังก์ชันต่อไปนี้เพื่อเลือกฟังก์ชันและประเภทแผนภูมิที่เหมาะกับวัตถุประสงค์ของคุณมากที่สุด

ฟังก์ชันแผนภูมิ

ใช้ผังแผนภูมิต่อไปนี้เป็นคำแนะนำภาพเพื่อทำความเข้าใจว่าแต่ละฟังก์ชันจัดเรียงผลลัพธ์การลดพื้นที่ในรูปภาพในแผนภูมิอย่างไร กล่าวคือ องค์ประกอบใดกำหนดค่า x, ค่า y และชุด

ui.Chart.image.byRegion

ระบบจะแสดงภูมิภาคการลดตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้องค์ประกอบที่เลือก ชุดจะกำหนดโดยชื่อย่านความถี่ที่มีการแสดงผลของการลดภูมิภาคตามแกน y

ui.Chart.image.regions

แถบจะแสดงตามแกน X ชุดข้อมูลจะติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้องค์ประกอบ การลดขนาดของภูมิภาคที่กําหนดโดยรูปเรขาคณิตของชุดข้อมูลที่เกี่ยวข้องจะแสดงบนแกน y

ui.Chart.image.byClass

แถบข้อมูลจะแสดงบนแกน X ชุดจะแสดงด้วยค่าที่ไม่ซ้ำกันในกลุ่มชั้น ตำแหน่งแกน Y กำหนดโดยผลลัพธ์การลดขนาดภูมิภาคสำหรับพิกเซลที่ประกอบกันเป็นชุดแต่ละชุด

ui.Chart.image.histogram

ฮิสโตแกรมความถี่สำหรับค่าของย่านความถี่ที่เลือก

  • แกน X: ที่เก็บข้อมูลฮิสโตแกรมสําหรับค่าของแถบความถี่ที่เลือก
  • แกน Y: ความถี่ของพิกเซลที่มีสิทธิ์สำหรับแต่ละที่เก็บข้อมูลฮิสโตแกรม

ตัวอย่างข้อมูล

ตัวอย่างต่อไปนี้ใช้ FeatureCollection ที่ประกอบด้วยองค์ประกอบเขตนิเวศ 3 รายการซึ่งกำหนดภูมิภาคที่จะลดข้อมูลรูปภาพ ข้อมูล Image คือค่าปกติของสภาพอากาศ PRISM ซึ่งแถบต่างๆ จะอธิบายตัวแปรสภาพอากาศในแต่ละเดือน เช่น ปริมาณน้ำฝนในเดือนกรกฎาคมหรืออุณหภูมิเฉลี่ยในเดือนมกราคม ดูวิธีสร้างชิ้นงานนี้

ui.Chart.image.byRegion

แผนภูมิคอลัมน์

ในตัวอย่างนี้ แถบภาพซึ่งแสดงอุณหภูมิเฉลี่ยรายเดือนจะลดลงเป็นค่าเฉลี่ยของพิกเซลที่ตัดกันในแต่ละเขตนิเวศ 3 เขต ระบบจะแสดงผลลัพธ์เป็นคอลัมน์ต่อเดือนตามเขตนิเวศ โดยความสูงของคอลัมน์จะแสดงอุณหภูมิเฉลี่ยรายเดือนที่เกี่ยวข้อง

เครื่องมือแก้ไขโค้ด (JavaScript)

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

// Load PRISM climate normals image collection; convert images to bands.
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .byRegion({
          image: normClim.select('[0-9][0-9]_tmean'),
          regions: ecoregions,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'label'
        })
        .setSeriesNames([
          'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
          'Nov', 'Dec'
        ])
        .setChartType('ColumnChart')
        .setOptions({
          title: 'Average Monthly Temperature by Ecoregion',
          hAxis:
              {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Temperature (°C)',
            titleTextStyle: {italic: false, bold: true}
          },
          colors: [
            '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
            'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
          ]
        });
print(chart);

แผนภูมิแท่ง

แผนภูมิคอลัมน์ก่อนหน้าจะแสดงผลเป็นแผนภูมิแท่งได้โดยการเปลี่ยนอินพุต .setChartType() จาก 'ColumnChart' เป็น 'BarChart'

var chart =
    ui.Chart.image
        .byRegion({
          image: normClim.select('[0-9][0-9]_tmean'),
          regions: ecoregions,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'label'
        })
        .setSeriesNames([
          'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
          'Nov', 'Dec'
        ])
        .setChartType('BarChart')
        .setOptions({
          title: 'Average Monthly Temperature by Ecoregion',
          hAxis: {
            title: 'Temperature (°C)',
            titleTextStyle: {italic: false, bold: true}
          },
          vAxis:
              {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
          colors: [
            '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
            'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
          ]
        });

แผนภูมิคอลัมน์แบบซ้อน

ตัวเลือกแผนภูมิ isStacked จะระบุให้คอลัมน์แผนภูมิซ้อนกันหรือไม่ มีตัวเลือกหลายรายการสําหรับการซ้อน ตัวอย่างต่อไปนี้แสดงการใช้ตัวเลือก 'absolute' และ 'relative'

สัมบูรณ์

แผนภูมิแท่งแบบซ้อนแบบสัมบูรณ์จะเชื่อมโยงผลรวมของตัวแปรที่เป็นตัวเลขกับการเพิ่มของชุดตัวแปรเชิงหมวดหมู่ที่ส่งผล ตัวอย่างเช่น ในตัวอย่างนี้ ปริมาณน้ำฝนทั้งหมดจะแสดงเป็นผังการสะสมของปริมาณน้ำฝนรายเดือนตลอดทั้งปีตามเขตนิเวศ ปริมาณน้ำฝนรายเดือนได้มาจากแถบภาพ โดยแต่ละแถบแสดงตารางกริดของปริมาณน้ำฝนทั้งหมดเฉลี่ยของเดือนหนึ่งๆ ซึ่งลดขนาดเป็นค่าเฉลี่ยของพิกเซลที่ตัดกันในแต่ละเขตนิเวศ 3 เขต ตัวเลือกแผนภูมิ isStacked มีการตั้งค่าเป็น 'absolute' เพื่อจัดรูปแบบผลลัพธ์เป็นค่าสัมบูรณ์

เครื่องมือแก้ไขโค้ด (JavaScript)

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

// Load PRISM climate normals image collection; convert images to bands.
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .byRegion({
          image: normClim.select('[0-9][0-9]_ppt'),
          regions: ecoregions,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'label'
        })
        .setSeriesNames([
          'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
          'Nov', 'Dec'
        ])
        .setChartType('ColumnChart')
        .setOptions({
          title: 'Average Monthly Precipitation by Ecoregion',
          hAxis:
              {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Precipitation (mm)',
            titleTextStyle: {italic: false, bold: true}
          },
          colors: [
            '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
            'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
          ],
          isStacked: 'absolute'
        });
print(chart);

ญาติ

แปลงแผนภูมิแท่งซ้อนแบบสัมบูรณ์ก่อนหน้านี้เป็นแผนภูมิแท่งซ้อนแบบสัมพัทธ์โดยเปลี่ยนตัวเลือกแผนภูมิ isStacked จาก 'absolute' เป็น 'relative' แผนภูมิแท่งแบบซ้อนแบบสัมพัทธ์จะแสดงสัดส่วนชุดตัวแปรเชิงหมวดหมู่ที่ส่งผลต่อผลรวมของตัวแปรเชิงตัวเลข ตัวอย่างเช่น ในตัวอย่างนี้ ปริมาณน้ำฝนรายเดือนจะแสดงเป็นเปอร์เซ็นต์ของปริมาณน้ำฝนทั้งหมดรายปีตามเขตนิเวศ

var chart =
    ui.Chart.image
        .byRegion({
          image: normClim.select('[0-9][0-9]_ppt'),
          regions: ecoregions,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'label'
        })
        .setSeriesNames([
          'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
          'Nov', 'Dec'
        ])
        .setChartType('ColumnChart')
        .setOptions({
          title: 'Average Monthly Precipitation by Ecoregion',
          hAxis:
              {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Precipitation (mm)',
            titleTextStyle: {italic: false, bold: true}
          },
          colors: [
            '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
            'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
          ],
          isStacked: 'relative'
        });

แผนภูมิกระจาย

อุณหภูมิเฉลี่ยในเดือนมกราคมและกรกฎาคมของตัวอย่างสถานที่แบบสุ่มในรัฐโคโลราโดแสดงเป็นกราฟตามระดับความสูง ระบบจะสุ่มตัวอย่าง DEM โดยใช้ฟังก์ชัน sample ซึ่งแสดงผล FeatureCollection ที่มีพร็อพเพอร์ตี้เรขาคณิตและระดับความสูง จากนั้นระบบจะใช้ FeatureCollection ที่ได้เป็นผลเป็นอาร์กิวเมนต์สำหรับพารามิเตอร์ regions ของฟังก์ชัน ui.Chart.image.byRegion ชุดข้อมูลจะกำหนดตามย่านความถี่ที่เลือกของภาพค่าปกติของสภาพภูมิอากาศอินพุต

เครื่องมือแก้ไขโค้ด (JavaScript)

// Load SRTM elevation data.
var elev = ee.Image('CGIAR/SRTM90_V4').select('elevation');

// Subset Colorado from the TIGER States feature collection.
var colorado = ee.FeatureCollection('TIGER/2018/States')
                   .filter(ee.Filter.eq('NAME', 'Colorado'));

// Draw a random sample of elevation points from within Colorado.
var samp = elev.sample(
    {region: colorado, scale: 30, numPixels: 500, geometries: true});

// Load PRISM climate normals image collection; convert images to bands.
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .byRegion({
                  image: normClim.select(['01_tmean', '07_tmean']),
                  regions: samp,
                  reducer: ee.Reducer.mean(),
                  scale: 500,
                  xProperty: 'elevation'
                })
                .setSeriesNames(['Jan', 'Jul'])
                .setChartType('ScatterChart')
                .setOptions({
                  title: 'Average Monthly Colorado Temperature by Elevation',
                  hAxis: {
                    title: 'Elevation (m)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  vAxis: {
                    title: 'Temperature (°C)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  pointSize: 4,
                  dataOpacity: 0.6,
                  colors: ['1d6b99', 'cf513e'],
                });
print(chart);

แผนภูมิผสม

สำหรับเขตนิเวศ 3 แห่งในee.FeatureCollection ระบบจะแสดงผังอุณหภูมิเฉลี่ยและการตกตะกอนในเดือนมิถุนายนของเขตนิเวศนั้นๆ ผลลัพธ์ที่ได้มาจากการตัดภาพให้เหลือเฉพาะภูมิภาค โดยแต่ละแถบคือตารางกริดของสภาพภูมิอากาศปกติที่อธิบายปริมาณน้ำฝนและอุณหภูมิรายเดือน ส่วนแถบที่แสดงอุณหภูมิและปริมาณน้ำฝนของเดือนมิถุนายนคือชุดย่อย เนื่องจากปริมาณน้ำฝนและอุณหภูมิอยู่ในหน่วยที่แตกต่างกัน ระบบจึงใช้แกน y 2 แกนโดยตั้งค่าตัวเลือก series และ vAxes โปรดสังเกตการใช้ตัวเลือก series.targetAxisIndex เพื่อกำหนดตัวแปรที่จะพล็อตบนแกน y ขวาและซ้าย ใช้สัญลักษณ์เฉพาะชุด (จุดและคอลัมน์) เพื่อแยกแยะตัวแปร 2 รายการที่มีหน่วยต่างกันได้ง่ายขึ้น

เครื่องมือแก้ไขโค้ด (JavaScript)

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

// Load PRISM climate normals image collection; convert images to bands.
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .byRegion({
          image: normClim.select(['06_tmean', '06_ppt']),
          regions: ecoregions,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'label'
        })
        .setSeriesNames(['Precipitation', 'Temperature'])
        .setChartType('ColumnChart')
        .setOptions({
          title: 'Average June Temperature and Precipitation by Ecoregion',
          series: {
            0: {targetAxisIndex: 1, type: 'bar', color: '1d6b99'},
            1: {
              targetAxisIndex: 0,
              type: 'line',
              lineWidth: 0,
              pointSize: 10,
              color: 'e37d05'
            }
          },
          hAxis:
              {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
          vAxes: {
            0: {
              title: 'Temperature (°C)',
              baseline: 0,
              titleTextStyle: {italic: false, bold: true, color: 'e37d05'}
            },
            1: {
              title: 'Precipitation (mm)',
              titleTextStyle: {italic: false, bold: true, color: '1d6b99'}
            },
          },
          bar: {groupWidth: '40%'},
        });
print(chart);

ui.Chart.image.regions

ตัวอย่างการตั้งค่า

ฟังก์ชัน ui.Chart.image.regions ยอมรับลิสต์ที่ช่วยให้คุณควบคุมป้ายกำกับและลําดับชื่อแถบตามแกน x ได้โดยกําหนดค่าตัวเลขให้กับแถบ แผนภูมิต่อไปนี้ใช้ตัวเลือกนี้เพื่อตั้งชื่อแถบเป็นป้ายกำกับเดือนและจัดเรียงตามลำดับเวลาสำหรับการตกสะสมรายเดือนโดยเฉลี่ย

แผนภูมิคอลัมน์

แผนภูมินี้แสดงปริมาณน้ำฝนเฉลี่ยทั้งหมดต่อเดือนสำหรับ 3 เขตนิเวศ ผลลัพธ์ที่ได้มาจากการปรับขนาดภูมิภาคของรูปภาพ โดยแต่ละแถบคือตารางกริดของปริมาณน้ำฝนทั้งหมดโดยเฉลี่ยของเดือนหนึ่งๆ ระบบจะแสดงแถบตามแนวแกน X และภูมิภาคจะกำหนดชุดข้อมูล โปรดสังเกตการดำเนินการฝั่งไคลเอ็นต์ที่ใช้เพื่อกำหนดอินพุตสำหรับตัวเลือกแผนภูมิ xLabels และ ticks สำหรับการจัดเรียงแกน x แบบกำหนดเอง จำเป็นต้องใช้การดำเนินการฝั่งไคลเอ็นต์เนื่องจากตัวเลือกที่ระบุให้กับฟังก์ชัน setOptions ต้องเป็นออบเจ็กต์ฝั่งไคลเอ็นต์ (ดูไคลเอ็นต์กับเซิร์ฟเวอร์เพื่อทําความเข้าใจความแตกต่าง) หากต้องการแปลงเป็นแผนภูมิแท่ง ให้ใช้ 'BarChart' เป็นอินพุต .setChartType()

เครื่องมือแก้ไขโค้ด (JavaScript)

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

// Load PRISM climate normals image collection, convert images to bands, and
// subset precipitation bands.
var precip = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m')
                 .toBands()
                 .select('[0-9][0-9]_ppt');

// Define a dictionary that associates band names with values and labels.
var precipInfo = {
  '01_ppt': {v: 1, f: 'Jan'},
  '02_ppt': {v: 2, f: 'Feb'},
  '03_ppt': {v: 3, f: 'Mar'},
  '04_ppt': {v: 4, f: 'Apr'},
  '05_ppt': {v: 5, f: 'May'},
  '06_ppt': {v: 6, f: 'Jun'},
  '07_ppt': {v: 7, f: 'Jul'},
  '08_ppt': {v: 8, f: 'Aug'},
  '09_ppt': {v: 9, f: 'Sep'},
  '10_ppt': {v: 10, f: 'Oct'},
  '11_ppt': {v: 11, f: 'Nov'},
  '12_ppt': {v: 12, f: 'Dec'}
};

// Organize precipitation information into objects for defining x values and
// their tick labels. Note that chart options provided to the .setOptions()
// function must be client-side objects, which is why a client-side for
// loop is used to iteratively populate lists from the above dictionary.
var xPropVals = [];    // List to codify x-axis band names as values.
var xPropLabels = [];  // Holds dictionaries that label codified x-axis values.
for (var key in precipInfo) {
  xPropVals.push(precipInfo[key].v);
  xPropLabels.push(precipInfo[key]);
}

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .regions({
                  image: precip,
                  regions: ecoregions,
                  reducer: ee.Reducer.mean(),
                  scale: 5e3,
                  seriesProperty: 'label',
                  xLabels: xPropVals
                })
                .setChartType('ColumnChart')
                .setOptions({
                  title: 'Average Ecoregion Precipitation by Month',
                  hAxis: {
                    title: 'Month',
                    titleTextStyle: {italic: false, bold: true},
                    ticks: xPropLabels
                  },
                  vAxis: {
                    title: 'Precipitation (mm)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  colors: ['f0af07', '0f8755', '76b349'],
                });
print(chart);

แผนภูมิเส้น

แผนภูมิคอลัมน์ก่อนหน้านี้จะแสดงผลเป็นแผนภูมิเส้นได้โดยการเปลี่ยนอินพุต .setChartType() จาก 'ColumnChart' เป็น 'LineChart'

var chart = ui.Chart.image
                .regions({
                  image: precip,
                  regions: ecoregions,
                  reducer: ee.Reducer.mean(),
                  scale: 500,
                  seriesProperty: 'label',
                  xLabels: xPropVals
                })
                .setChartType('LineChart')
                .setOptions({
                  title: 'Average Ecoregion Precipitation by Month',
                  hAxis: {
                    title: 'Month',
                    titleTextStyle: {italic: false, bold: true},
                    ticks: xPropLabels
                  },
                  vAxis: {
                    title: 'Precipitation (mm)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  colors: ['f0af07', '0f8755', '76b349'],
                  lineSize: 5
                });

แผนภูมิพื้นที่

แผนภูมิคอลัมน์ก่อนหน้าจะแสดงผลเป็นแผนภูมิพื้นที่ได้โดยการเปลี่ยนอินพุต .setChartType() จาก 'ColumnChart' เป็น 'AreaChart'

var chart = ui.Chart.image
                .regions({
                  image: precip,
                  regions: ecoregions,
                  reducer: ee.Reducer.mean(),
                  scale: 500,
                  seriesProperty: 'label',
                  xLabels: xPropVals
                })
                .setChartType('AreaChart')
                .setOptions({
                  title: 'Average Ecoregion Precipitation by Month',
                  hAxis: {
                    title: 'Month',
                    titleTextStyle: {italic: false, bold: true},
                    ticks: xPropLabels
                  },
                  vAxis: {
                    title: 'Precipitation (mm)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  colors: ['f0af07', '0f8755', '76b349'],
                  lineSize: 5
                });

แผนภูมิวงกลม

ปริมาณน้ำฝนรายเดือนเฉลี่ยจะแสดงเป็นเปอร์เซ็นต์ของปริมาณน้ำฝนทั้งหมดเฉลี่ยรายปีสำหรับเขตนิเวศป่าไม้ แถบภาพซึ่งแสดงปริมาณน้ำฝนรายเดือนคือชุดย่อยจากชุดข้อมูลสภาพอากาศปกติและลดลงเป็นค่าเฉลี่ยของพิกเซลที่ตัดกันกับเขตนิเวศ

เครื่องมือแก้ไขโค้ด (JavaScript)

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

// Load PRISM climate normals image collection, convert images to bands.
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();

// Define x-axis labels to replace default band names.
var monthNames = [
  'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',
  'Dec'
];

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .regions({
                  image: normClim.select('[0-9][0-9]_ppt'),
                  regions: forest,
                  reducer: ee.Reducer.mean(),
                  scale: 5e3,
                  seriesProperty: 'label',
                  xLabels: monthNames
                })
                .setChartType('PieChart')
                .setOptions({
                  title: 'Average Monthly Precipitation for Forest Ecoregion',
                  colors: [
                    '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
                    'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
                  ]
                });
print(chart);

แผนภูมิโดนัท

แปลงตัวอย่างแผนภูมิวงกลมเป็นแผนภูมิโดนัทโดยการตั้งค่าตัวเลือกแผนภูมิ pieHole ลองใช้ 0.4 และ 0.6 เป็นค่าเริ่มต้น

var chart = ui.Chart.image
                .regions({
                  image: normClim.select('[0-9][0-9]_ppt'),
                  regions: forest,
                  reducer: ee.Reducer.mean(),
                  scale: 5e3,
                  seriesProperty: 'label',
                  xLabels: monthNames
                })
                .setChartType('PieChart')
                .setOptions({
                  title: 'Average Monthly Precipitation for Forest Ecoregion',
                  colors: [
                    '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
                    'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
                  ],
                  pieHole: 0.4
                });

ui.Chart.image.byClass

แผนภูมิเส้น

ฟังก์ชัน ui.Chart.image.byClass จะแสดงสถิติค่าแถบสำหรับพิกเซลภายในภูมิภาคที่จัดประเภทของ "แถบคลาส" ในตัวอย่างนี้ ระบบใช้เพื่อแสดงโปรไฟล์สเปกตรัมของเขตนิเวศ 3 แห่ง ระบบจะแรสเตอร์องค์ประกอบของเขตนิเวศและเพิ่มเป็นแถบในรูปภาพการสะท้อนแสงพื้นผิว (SR) ของ MODIS ระบบจะคำนวณค่าเฉลี่ยพิกเซลที่เกี่ยวข้องและพล็อตลงในแกน Y สำหรับแต่ละชั้นลุ่มน้ำและย่านความถี่การสะท้อนแสง ความยาวคลื่นกลางของแถบ MODIS SR จะกำหนดเครื่องหมายและป้ายกำกับบนแกน x โปรดทราบว่าตัวเลือกแผนภูมิเส้น curveType ได้รับการตั้งค่าเป็น 'function' เพื่อทำให้เส้นเรียบ

เครื่องมือแก้ไขโค้ด (JavaScript)

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

// Convert ecoregion feature collection to a classified image.
var regionsBand =
    ecoregions
        .reduceToImage({properties: ['value'], reducer: ee.Reducer.first()})
        .rename('class');

// Define a MODIS surface reflectance composite.
var modisSr = ee.ImageCollection('MODIS/006/MOD09A1')
                  .filter(ee.Filter.date('2018-06-01', '2018-09-01'))
                  .select('sur_refl_b0[0-7]')
                  .mean();

// Reorder reflectance bands by ascending wavelength and
// add the classified ecoregions image as a band to the SR collection and
var modisSrClass = modisSr.select([2, 3, 0, 1, 4, 5, 6]).addBands(regionsBand);

// Define a list of MODIS SR wavelengths for x-axis labels.
var wavelengths = [469, 555, 655, 858, 1240, 1640, 2130];

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .byClass({
                  image: modisSrClass,
                  classBand: 'class',
                  region: ecoregions,
                  reducer: ee.Reducer.mean(),
                  scale: 500,
                  classLabels: ['Desert', 'Forest', 'Grassland'],
                  xLabels: wavelengths
                })
                .setChartType('ScatterChart')
                .setOptions({
                  title: 'Ecoregion Spectral Signatures',
                  hAxis: {
                    title: 'Wavelength (nm)',
                    titleTextStyle: {italic: false, bold: true},
                    viewWindow: {min: wavelengths[0], max: wavelengths[6]}
                  },
                  vAxis: {
                    title: 'Reflectance (x1e4)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  colors: ['f0af07', '0f8755', '76b349'],
                  pointSize: 0,
                  lineSize: 5,
                  curveType: 'function'
                });
print(chart);

ui.Chart.image.histogram

ฮิสโตแกรมของค่าพิกเซลภายในภูมิภาครอบๆ ซอลต์เลกซิตี รัฐยูทาห์ สหรัฐอเมริกาจะแสดงสำหรับย่านการสะท้อนแสงพื้นผิวของ MODIS 3 ย่าน

เครื่องมือแก้ไขโค้ด (JavaScript)

// Define a MODIS surface reflectance composite.
var modisSr = ee.ImageCollection('MODIS/006/MOD09A1')
                  .filter(ee.Filter.date('2018-06-01', '2018-09-01'))
                  .select(['sur_refl_b01', 'sur_refl_b02', 'sur_refl_b06'])
                  .mean();

// Define a region to calculate histogram for.
var histRegion = ee.Geometry.Rectangle([-112.60, 40.60, -111.18, 41.22]);

// Define the chart and print it to the console.
var chart =
    ui.Chart.image.histogram({image: modisSr, region: histRegion, scale: 500})
        .setSeriesNames(['Red', 'NIR', 'SWIR'])
        .setOptions({
          title: 'MODIS SR Reflectance Histogram',
          hAxis: {
            title: 'Reflectance (x1e4)',
            titleTextStyle: {italic: false, bold: true},
          },
          vAxis:
              {title: 'Count', titleTextStyle: {italic: false, bold: true}},
          colors: ['cf513e', '1d6b99', 'f0af07']
        });
print(chart);