ee.Kernel.fixed

  • The ee.Kernel.fixed() method creates a Kernel object.

  • This method takes optional arguments for width, height, x and y focus locations, and a boolean to normalize the weights, but requires a 2-D list of weights.

  • The weights argument should be a 2-D list with dimensions matching the height and width of the kernel.

  • Examples in JavaScript and Python demonstrate how to create a fixed kernel using a list of weights.

Creates a Kernel.

UsageReturns
ee.Kernel.fixed(width, height, weights, x, y, normalize)Kernel
ArgumentTypeDetails
widthInteger, default: -1The width of the kernel in pixels.
heightInteger, default: -1The height of the kernel in pixels.
weightsListA 2-D list of [height] x [width] values to use as the weights of the kernel.
xInteger, default: -1The location of the focus, as an offset from the left.
yInteger, default: -1The location of the focus, as an offset from the top.
normalizeBoolean, default: falseNormalize the kernel values to sum to 1.

Examples

Code Editor (JavaScript)

// Kernel weights.
var weights = [[4, 3, 2, 1, 2, 3, 4],
               [4, 3, 2, 1, 2, 3, 4],
               [4, 3, 2, 1, 2, 3, 4]];

print('A fixed kernel', ee.Kernel.fixed({weights: weights}));

/**
 * Output weights matrix
 *
 * [4, 3, 2, 1, 2, 3, 4]
 * [4, 3, 2, 1, 2, 3, 4]
 * [4, 3, 2, 1, 2, 3, 4]
 */

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

weights = [[4, 3, 2, 1, 2, 3, 4],
           [4, 3, 2, 1, 2, 3, 4],
           [4, 3, 2, 1, 2, 3, 4]]

display('A fixed kernel:', ee.Kernel.fixed(**{'weights': weights}))

#  Output weights matrix

#  [4, 3, 2, 1, 2, 3, 4]
#  [4, 3, 2, 1, 2, 3, 4]
#  [4, 3, 2, 1, 2, 3, 4]