Announcement: On November 13, 2024, all users will need to use a Cloud project in order to access Earth Engine. After this date, continued individual access without a Cloud project will require an exception.
Stay organized with collections
Save and categorize content based on your preferences.
You can compute the gradient of each band of an image with image.gradient().
For example, the following code computes the gradient magnitude and direction of the
Landsat 8 panchromatic band:
Note that gradient() outputs two bands: the gradient in the X-direction and the
gradient in the Y-direction. As shown in the example, the two directions can be combined to
get gradient magnitude and direction. The magnitude should look something like Figure 1.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["The `image.gradient()` function in Earth Engine calculates the gradient of each band in an image, providing information on the rate of change in pixel values."],["The output of `image.gradient()` includes two bands: 'x' representing the gradient in the horizontal direction and 'y' representing the gradient in the vertical direction."],["Gradient magnitude and direction can be derived from the 'x' and 'y' gradient bands using mathematical operations like squaring, addition, square root, and atan2."],["Visualizing gradient magnitude helps in identifying areas with significant changes in pixel values, such as edges and textures within an image."]]],[]]