ग्रेडिएंट

image.gradient() का इस्तेमाल करके, इमेज के हर बैंड के ग्रेडिएंट का हिसाब लगाया जा सकता है. उदाहरण के लिए, यह कोड, Landsat 8 के पैनक्रोमैटिक बैंड के ग्रेडिएंट मैग्नीट्यूड और दिशा का हिसाब लगाता है:

कोड एडिटर (JavaScript)

// Load a Landsat 8 image and select the panchromatic band.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318').select('B8');

// Compute the image gradient in the X and Y directions.
var xyGrad = image.gradient();

// Compute the magnitude of the gradient.
var gradient = xyGrad.select('x').pow(2)
          .add(xyGrad.select('y').pow(2)).sqrt();

// Compute the direction of the gradient.
var direction = xyGrad.select('y').atan2(xyGrad.select('x'));

// Display the results.
Map.setCenter(-122.054, 37.7295, 10);
Map.addLayer(direction, {min: -2, max: 2, format: 'png'}, 'direction');
Map.addLayer(gradient, {min: -7, max: 7, format: 'png'}, 'gradient');

ध्यान दें कि gradient() दो बैंड दिखाता है: X-दिशा में ग्रेडिएंट और Y-दिशा में ग्रेडिएंट. उदाहरण में दिखाए गए तरीके के मुताबिक, ग्रेडिएंट का मैग्नीट्यूड और दिशा पाने के लिए, दोनों दिशाओं को जोड़ा जा सकता है. मैग्नीट्यूड कुछ ऐसा दिखना चाहिए जैसा कि पहली इमेज में दिखाया गया है.

gradient_sf
पहली इमेज. अमेरिका के कैलिफ़ोर्निया में सैन फ़्रांसिस्को बे एरिया के ऊपर, Landsat 8 इमेजरी के लिए पैनक्रोमैटिक ग्रेडिएंट मैग्नीट्यूड.