ee.Kernel.fixed

  • Creates a kernel to be applied to an image, using a fixed set of weights provided in a 2-D list.

  • The kernel can be customized with dimensions (width, height), weight values, and a central focus point (x, y).

  • Optionally, the kernel weights can be normalized to sum to 1.

  • Examples in JavaScript, Python, and Colab are included to demonstrate how to create and use a fixed kernel.

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)

from pprint import pprint

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:')
pprint(ee.Kernel.fixed(**{'weights': weights}).getInfo())

#  Output weights matrix

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