ui.Chart.array.values
फ़ंक्शन, ee.Array
और ee.List
ऑब्जेक्ट से चार्ट रेंडर करने का तरीका उपलब्ध कराता है.
यहां दिए गए उदाहरण, ee.Reducer.toList()
रिड्यूसर का इस्तेमाल करके इमेज बैंड और इमेज मेटाडेटा को कम करके जनरेट किए गए ऐरे और सूची के डेटा पर निर्भर करते हैं. ध्यान दें कि किसी दिए गए ऐक्सिस के साथ एक जैसी लंबाई वाली सूचियों और/या ऐरे के किसी भी सेट को ui.Chart.array.values
से प्लॉट किया जा सकता है.
ee.Array
क्षेत्र का स्कैटर प्लॉट
ee.Reducer.toList()
की मदद से इमेज के क्षेत्र को छोटा करने पर, पिक्सल वैल्यू की सूचियों की एक डिक्शनरी बनती है. यह सूची, किसी इमेज के हर बैंड के लिए एक होती है. यहां इसका इस्तेमाल, वन वाले इको-क्षेत्र से इंटरसेक्शन करने वाले पिक्सल के लिए, MODIS इमेज से रेड, एनआईआर, और एसडब्ल्यूआईआर रिफ़्लेक्शन वैल्यू की सूचियों को निकालने के लिए किया गया है. रेड रिफ़्लेक्शन वैल्यू को x-ऐक्सिस पर प्लॉट किया जाता है. NIR और SWIR वैल्यू को y-ऐक्सिस पर प्लॉट किया जाता है.
इस उदाहरण में, projects/google/charts_feature_example ऐसेट का इस्तेमाल, जंगल वाले इको-क्षेत्र को दिखाने के लिए किया गया है. इसे उदाहरण के तौर पर दिखाने के लिए डेवलप किया गया था. यह तीन इको-क्षेत्र पॉलीगॉन का एक कलेक्शन है. इसमें, जलवायु के सामान्य आंकड़े बताने वाली प्रॉपर्टी शामिल हैं.
कोड एडिटर (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')); // 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(); // Reduce MODIS reflectance bands by forest region; get a dictionary with // band names as keys, pixel values as lists. var pixelVals = modisSr.reduceRegion( {reducer: ee.Reducer.toList(), geometry: forest.geometry(), scale: 2000}); // Convert NIR and SWIR value lists to an array to be plotted along the y-axis. var yValues = pixelVals.toArray(['sur_refl_b02', 'sur_refl_b06']); // Get the red band value list; to be plotted along the x-axis. var xValues = ee.List(pixelVals.get('sur_refl_b01')); // Define the chart and print it to the console. var chart = ui.Chart.array.values({array: yValues, axis: 1, xLabels: xValues}) .setSeriesNames(['NIR', 'SWIR']) .setOptions({ title: 'Relationship Among Spectral Bands for Forest Pixels', colors: ['1d6b99', 'cf513e'], pointSize: 4, dataOpacity: 0.4, hAxis: { 'title': 'Red reflectance (x1e4)', titleTextStyle: {italic: false, bold: true} }, vAxis: { 'title': 'Reflectance (x1e4)', titleTextStyle: {italic: false, bold: true} } }); print(chart);
ee.List
क्षेत्र का स्कैटर प्लॉट
ui.Chart.array.values
फ़ंक्शन का इस्तेमाल करके, दो सूची ऑब्जेक्ट प्लॉट किए जा सकते हैं.
पिछले उदाहरण के आधार पर, लाल और SWIR रेफ़्लेक्शन को दिखाने वाली x- और y-ऐक्सिस वैल्यू की सूचियों को स्कैटर प्लॉट के तौर पर रेंडर किया जाता है.
कोड एडिटर (JavaScript)
// Get Red and SWIR value lists; to be plotted along x and y axes, respectively. // Note that the pixelVals object is defined in the previous code block. var x = ee.List(pixelVals.get('sur_refl_b01')); var y = ee.List(pixelVals.get('sur_refl_b06')); // Define the chart and print it to the console. var chart = ui.Chart.array.values({array: y, axis: 0, xLabels: x}).setOptions({ title: 'Relationship Among Spectral Bands for Forest Pixels', colors: ['cf513e'], hAxis: { title: 'Red reflectance (x1e4)', titleTextStyle: {italic: false, bold: true} }, vAxis: { title: 'SWIR reflectance (x1e4)', titleTextStyle: {italic: false, bold: true} }, pointSize: 4, dataOpacity: 0.4, legend: {position: 'none'}, }); print(chart);
ee.List
ट्रांसेक्ट लाइन प्लॉट
ee.Reducer.toList()
की मदद से इमेज के क्षेत्र को छोटा करने पर, पिक्सल वैल्यू की सूचियों की एक डिक्शनरी बनती है. हर इमेज बैंड के लिए एक सूची बनती है. अगर इलाका एक लाइन है, जैसा कि इस मामले में है, तो दिलचस्पी की इमेज में अक्षांश और देशांतर बैंड को बैंड के तौर पर शामिल करने पर, भौगोलिक ट्रांसेक्शन जनरेट किया जा सकता है. यहां, ट्रांज़ेक्ट लाइन के साथ-साथ, देशांतर और ऊंचाई की पिक्सल वैल्यू की सूचियों को अलग-अलग वैरिएबल के तौर पर निकाला जाता है और उन्हें x- और y-ऐक्सिस पर प्लॉट किया जाता है.
कोड एडिटर (JavaScript)
// Define a line across the Olympic Peninsula, USA. var transect = ee.Geometry.LineString([[-122.8, 47.8], [-124.5, 47.8]]); // Define a pixel coordinate image. var latLonImg = ee.Image.pixelLonLat(); // Import a digital surface model and add latitude and longitude bands. var elevImg = ee.Image('NASA/NASADEM_HGT/001').select('elevation').addBands(latLonImg); // Reduce elevation and coordinate bands by transect line; get a dictionary with // band names as keys, pixel values as lists. var elevTransect = elevImg.reduceRegion({ reducer: ee.Reducer.toList(), geometry: transect, scale: 1000, }); // Get longitude and elevation value lists from the reduction dictionary. var lon = ee.List(elevTransect.get('longitude')); var elev = ee.List(elevTransect.get('elevation')); // Sort the longitude and elevation values by ascending longitude. var lonSort = lon.sort(lon); var elevSort = elev.sort(lon); // Define the chart and print it to the console. var chart = ui.Chart.array.values({array: elevSort, axis: 0, xLabels: lonSort}) .setOptions({ title: 'Elevation Profile Across Longitude', hAxis: { title: 'Longitude', viewWindow: {min: -124.50, max: -122.8}, titleTextStyle: {italic: false, bold: true} }, vAxis: { title: 'Elevation (m)', titleTextStyle: {italic: false, bold: true} }, colors: ['1d6b99'], lineSize: 5, pointSize: 0, legend: {position: 'none'} }); print(chart);
लाइन के नीचे शेडिंग जोड़ने के लिए, .setChartType('AreaChart')
लागू करें:
print(chart.setChartType('AreaChart'));
ee.List
मेटाडेटा स्कैटर प्लॉट
ee.Reducer.toList()
की मदद से कलेक्शन प्रॉपर्टी को कम करने पर, प्रॉपर्टी की वैल्यू की सूचियों की एक डिक्शनरी बनती है. यह सूची, चुनी गई हर प्रॉपर्टी के लिए अलग-अलग होती है. यहां, Landsat 8 की इमेज के सेट से अलग-अलग वैरिएबल के तौर पर, बादल के कवर और ज्यामितीय आरएमएसई प्रॉपर्टी की सूचियां जनरेट की गई हैं. बादल की कवरेज वाले वैरिएबल को x-ऐक्सिस पर प्लॉट किया गया है और जियोमेट्रिक आरएमएसई को y-ऐक्सिस पर प्लॉट किया गया है.
कोड एडिटर (JavaScript)
// Import a Landsat 8 collection and filter to a single path/row. var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2') .filter(ee.Filter.expression('WRS_PATH == 45 && WRS_ROW == 30')); // Reduce image properties to a series of lists; one for each selected property. var propVals = col.reduceColumns({ reducer: ee.Reducer.toList().repeat(2), selectors: ['CLOUD_COVER', 'GEOMETRIC_RMSE_MODEL'] }) .get('list'); // Get selected image property value lists; to be plotted along x and y axes. var x = ee.List(ee.List(propVals).get(0)); var y = ee.List(ee.List(propVals).get(1)); // Define the chart and print it to the console. var chart = ui.Chart.array.values({array: y, axis: 0, xLabels: x}) .setChartType('ScatterChart') .setOptions({ title: 'Landsat 8 Image Collection Metadata (045030)', colors: ['96356f'], hAxis: { title: 'Cloud cover (%)', titleTextStyle: {italic: false, bold: true} }, vAxis: { title: 'Geometric RMSE (m)', titleTextStyle: {italic: false, bold: true} }, pointSize: 5, dataOpacity: 0.6, legend: {position: 'none'}, }); print(chart);
ee.List
मैप किए गए फ़ंक्शन का स्कैटर और लाइन प्लॉट
x वैल्यू की सूची पर फ़ंक्शन को मैप करके, y वैल्यू की सूची का हिसाब लगाएं. यहां sin()
फ़ंक्शन को x-ऐक्सिस की वैल्यू की सूची पर मैप किया गया है, ताकि y-ऐक्सिस की वैल्यू की सूची बनाई जा सके. x और y सूचियों को प्लॉट करने पर, साइन वेव का सैंपल दिखता है.
कोड एडिटर (JavaScript)
// Define a sequence from -2pi to +2pi in 50 increments. var start = -2 * Math.PI; var end = 2 * Math.PI; var points = ee.List.sequence(start, end, null, 50); // Evaluate the sin() function for each value in the points sequence. var values = points.map(function(val) { return ee.Number(val).sin(); }); // Define the chart and print it to the console. var chart = ui.Chart.array.values({array: values, axis: 0, xLabels: points}) .setOptions({ title: 'Sine Function', hAxis: { title: 'radians', viewWindowMode: 'maximized', ticks: [ {v: start, f: '-2π'}, {v: -Math.PI, f: '-π'}, {v: 0, f: '0'}, {v: Math.PI, f: 'π'}, {v: end, f: '2π'} ], titleTextStyle: {italic: false, bold: true} }, vAxis: { title: 'sin(x)', titleTextStyle: {italic: false, bold: true} }, colors: ['39a8a7'], lineWidth: 3, pointSize: 7, viewWindow: {min: start, max: end}, legend: {position: 'none'} }); print(chart);