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 Google Earth Engine calculates the gradient of each band in an image, yielding X and Y direction components."],["By combining the X and Y gradient components, you can derive both the gradient magnitude and direction."],["The gradient magnitude represents the rate of change in pixel values, while the direction indicates the orientation of this change."],["Visualizing the gradient can highlight areas of rapid change in the image, such as edges and textures."],["This functionality is demonstrated using Landsat 8 panchromatic data, showcasing the gradient over the San Francisco Bay area."]]],[]]