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.
Usage Returns
ee.Kernel.fixed( width , height , weights, x , y , normalize ) Kernel
Argument Type Details
width
Integer, default: -1 The width of the kernel in pixels.
height
Integer, default: -1 The height of the kernel in pixels.
weights
List A 2-D list of [height] x [width] values to use as the weights of the kernel.
x
Integer, default: -1 The location of the focus, as an offset from the left.
y
Integer, default: -1 The location of the focus, as an offset from the top.
normalize
Boolean, default: false Normalize 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] 
Design a Mobile Site
View Site in Mobile | Classic
Share by: