Gradientes

É possível calcular o gradiente de cada banda de uma imagem com image.gradient(). Por exemplo, o código a seguir calcula a magnitude e a direção do gradiente da banda pancromática do Landsat 8:

// 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() gera duas faixas: o gradiente na direção X e o gradiente na direção Y. Como mostrado no exemplo, as duas direções podem ser combinadas para obter a magnitude e a direção do gradiente. A magnitude deve ser semelhante à Figura 1.

gradient_sf
Figura 1. Magnitude do gradiente pancromático para as imagens do Landsat 8 sobre a área da Baía de São Francisco, Califórnia, EUA.