منحدرات

يمكنك احتساب التدرّج اللوني لكل نطاق من الصورة باستخدام 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. كما هو موضّح في المثال، يمكن دمج الاتجاهَين لتحديد شدة التدرّج واتجاهه. من المفترض أن يظهر مقدار الزلزال بالشكل الموضّح في الشكل 1.

gradient_sf
الشكل 1. شدة التدرّج اللوني للصور البانورامية من Landsat 8 فوق منطقة خليج سان فرانسيسكو، كاليفورنيا، الولايات المتحدة