इमेज चार्ट

ui.Chart.image मॉड्यूल में, क्षेत्र के हिसाब से Image ऑब्जेक्ट को कम करने और नतीजों से चार्ट रेंडर करने के लिए, फ़ंक्शन का एक सेट शामिल है. फ़ंक्शन चुनने से, चार्ट में डेटा का क्रम तय होता है. इसका मतलब है कि x- और y-ऐक्सिस की वैल्यू और सीरीज़ को किस आधार पर तय किया जाएगा. अपने काम के लिए सबसे अच्छा फ़ंक्शन और चार्ट टाइप तय करने के लिए, यहां दिए गए फ़ंक्शन की जानकारी और उदाहरणों का इस्तेमाल करें.

चार्ट फ़ंक्शन

नीचे दिए गए प्लॉट डायग्राम को विज़ुअल गाइड के तौर पर इस्तेमाल करें.इससे यह समझने में मदद मिलेगी कि हर फ़ंक्शन, इमेज के क्षेत्र को कम करने के नतीजों को चार्ट में कैसे व्यवस्थित करता है. इसका मतलब है कि कौनसे एलिमेंट, x वैल्यू, y वैल्यू, और सीरीज़ तय करते हैं.

ui.Chart.image.byRegion

कमी वाले इलाकों को एक्स-ऐक्सिस पर प्लॉट किया जाता है. साथ ही, उन्हें चुनी गई फ़ीचर प्रॉपर्टी की वैल्यू के हिसाब से लेबल किया जाता है. सीरीज़ को बैंड के नाम से तय किया जाता है. क्षेत्र में कमी के नतीजों को y-ऐक्सिस पर प्लॉट किया जाता है.

ui.Chart.image.regions

बैंड, x-ऐक्सिस पर प्लॉट किए जाते हैं. सीरीज़ को किसी फ़ीचर प्रॉपर्टी की वैल्यू के हिसाब से लेबल किया जाता है. सीरीज़ की ज्यामिति के हिसाब से तय किए गए क्षेत्र को कम करने पर, y-ऐक्सिस पर प्लॉट किया जाता है.

ui.Chart.image.byClass

डेटा बैंड, x-ऐक्सिस पर प्लॉट किए जाते हैं. सीरीज़ को क्लास बैंड में यूनीक वैल्यू के ज़रिए दिखाया जाता है. Y-ऐक्सिस की पोज़िशन, हर सीरीज़ को बनाने वाले पिक्सल के लिए क्षेत्र में कमी के नतीजों से तय होती है.

ui.Chart.image.histogram

चुने गए बैंड की वैल्यू के लिए फ़्रीक्वेंसी हिस्टोग्राम.

  • X-ऐक्सिस: चुने गए बैंड की वैल्यू के लिए हिस्टोग्राम बकेट
  • Y-ऐक्सिस: हर हिस्टोग्राम बकेट के लिए ज़रूरी शर्तें पूरी करने वाले पिक्सल की फ़्रीक्वेंसी

डेटा का उदाहरण

यहां दिए गए उदाहरण, FeatureCollection पर आधारित हैं. यह FeatureCollection, तीन इको-क्षेत्र की सुविधाओं से बना है. इन सुविधाओं से उन क्षेत्रों की जानकारी मिलती है जिनसे इमेज का डेटा कम किया जा सकता है. Image डेटा, PRISM के सामान्य मौसम से जुड़ा डेटा होता है.इसमें हर महीने के हिसाब से, मौसम से जुड़े वैरिएबल के बारे में जानकारी होती है. उदाहरण के लिए, जुलाई में हुई बारिश या जनवरी का औसत तापमान. जानें कि यह ऐसेट कैसे बनाई गई.

ui.Chart.image.byRegion

कॉलम चार्ट

इस उदाहरण में, हर महीने के औसत तापमान को दिखाने वाले इमेज बैंड को, तीनों इको-रीजन के इंटरसेक्शन वाले पिक्सल के बीच के औसत तक कम किया गया है. नतीजों को हर महीने के हिसाब से, कॉलम के तौर पर प्लॉट किया जाता है. कॉलम की ऊंचाई से, उस महीने का औसत तापमान पता चलता है.

कोड एडिटर (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' विकल्पों के इस्तेमाल के बारे में बताया गया है.

समुद्र तल के निरपेक्ष

एब्सोलूट स्टैक किया गया बार चार्ट, किसी कैटगरी वाले वैरिएबल की सीरीज़ में हुई बढ़ोतरी के हिसाब से, किसी अंकों वाले वैरिएबल की कुल वैल्यू दिखाता है. उदाहरण के लिए, इस उदाहरण में, कुल बारिश को एक साल में हर महीने हुई बारिश के हिसाब से प्लॉट किया गया है. साथ ही, इसे इको-क्षेत्र के हिसाब से दिखाया गया है. हर महीने होने वाली बारिश की कुल मात्रा, इमेज बैंड से मिलती है. हर बैंड, किसी महीने में होने वाली बारिश की औसत मात्रा के ग्रिड को दिखाता है. इसे तीनों इको-रीजन के इंटरसेक्शन वाले पिक्सल के औसत तक कम किया जाता है. नतीजों को एब्सोल्यूट वैल्यू के तौर पर फ़ॉर्मैट करने के लिए, 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'
        });

स्कैटर चार्ट

कोलोराडो राज्य की चुनिंदा जगहों के जनवरी और जुलाई के औसत तापमान को, ऊंचाई के फ़ंक्शन के तौर पर प्लॉट किया गया है. sample फ़ंक्शन का इस्तेमाल करके, डीईएम का सैंपल लिया जाता है. यह फ़ंक्शन, ज्यामिति और ऊंचाई की प्रॉपर्टी के साथ FeatureCollection दिखाता है. इसके बाद, FeatureCollection का इस्तेमाल ui.Chart.image.byRegion फ़ंक्शन के regions पैरामीटर के आर्ग्युमेंट के तौर पर किया जाता है. सीरीज़, इनपुट क्लाइमेट नॉर्मल इमेज के चुने गए बैंड के हिसाब से तय की जाती हैं.

कोड एडिटर (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);

कॉम्बो चार्ट

ee.FeatureCollection में मौजूद तीन इको-क्षेत्रों के लिए, जून के औसत तापमान और बारिश को प्लॉट किया गया है. ये नतीजे, किसी इमेज के क्षेत्र को छोटा करने से मिलते हैं. इसमें हर बैंड, जलवायु के सामान्य ग्रिड होता है, जिसमें हर महीने की बारिश और तापमान की जानकारी होती है. जून के तापमान और बारिश को दिखाने वाले बैंड, सबसेट होते हैं. बारिश और तापमान की जानकारी अलग-अलग इकाइयों में दी गई है. इसलिए, series और vAxes विकल्पों को सेट करके, दो y-ऐक्स का इस्तेमाल किया जाता है. series.targetAxisIndex विकल्प का इस्तेमाल करके, यह तय करें कि किस वैरिएबल को दाईं और बाईं ओर मौजूद y-ऐक्सिस पर प्लॉट किया जाए. सीरीज़ के हिसाब से सिंबल (पॉइंट और कॉलम) का इस्तेमाल करके, दो वैरिएबल को आसानी से अलग-अलग यूनिट के तौर पर पहचाना जा सकता है.

कोड एडिटर (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-ऐक्सिस पर बैंड के नामों के लेबल और क्रम को कंट्रोल किया जा सकता है. इसके लिए, बैंड के नामों को संख्या वाली वैल्यू असाइन करें. नीचे दिए गए चार्ट, इस विकल्प का इस्तेमाल करके बैंड के नामों को महीने के लेबल के तौर पर सेट करते हैं. साथ ही, उन्हें महीने के औसत बारिश के हिसाब से, समय के क्रम में क्रम से लगाते हैं.

कॉलम चार्ट

इस चार्ट में, तीन इको-क्षेत्रों के लिए हर महीने की औसत बारिश की जानकारी दी गई है. ये नतीजे, किसी इमेज के क्षेत्र को छोटा करने से मिलते हैं. इसमें हर बैंड, किसी महीने में औसत बारिश के ग्रिड के तौर पर काम करता है. बैंड को X-ऐक्सिस के साथ प्लॉट किया जाता है और क्षेत्र, सीरीज़ तय करते हैं. ध्यान दें कि x-ऐक्सिस को पसंद के मुताबिक व्यवस्थित करने के लिए, xLabels और ticks चार्ट के विकल्पों के लिए इनपुट तय करने के लिए, क्लाइंट-साइड ऑपरेशन का इस्तेमाल किया जाता है. क्लाइंट ऑपरेशन ज़रूरी हैं, क्योंकि setOptions फ़ंक्शन के लिए दिए गए विकल्प, क्लाइंट-साइड ऑब्जेक्ट होने चाहिए. अंतर को समझने के लिए, क्लाइंट बनाम सर्वर देखें. बार चार्ट में बदलने के लिए, .setChartType() इनपुट के तौर पर 'BarChart' का इस्तेमाल करें.

कोड एडिटर (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 फ़ंक्शन, "क्लास बैंड" के अलग-अलग कैटगरी वाले क्षेत्रों में पिक्सल के लिए, बैंड वैल्यू के आंकड़े प्लॉट करता है. इस उदाहरण में, इसका इस्तेमाल तीन इको-रीजन की स्पेक्ट्रल प्रोफ़ाइल दिखाने के लिए किया गया है. इकोरिज़न की सुविधाओं को रेस्टर में बदला जाता है और MODIS की सतह की रिफ़्लेक्शन (एसआर) इमेज में बैंड के तौर पर जोड़ा जाता है. हर इको-क्षेत्र क्लास और रिफ़्लेक्शन बैंड के लिए, पिक्सल का औसत निकाला जाता है और उसे y-ऐक्सिस पर प्लॉट किया जाता है. MODIS SR बैंड की सेंट्रल वेवलेंथ, एक्स-ऐक्सिस के टिक और लेबल तय करती हैं. ध्यान दें कि लाइनों को आसानी से पढ़ने के लिए, 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 की सतह की रिफ़्लेक्शन बैंड के तीनों बैंड के लिए दिखाया गया है.

कोड एडिटर (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);