ee.Image.neighborhoodToArray

Turns the neighborhood of each pixel in a scalar image into a 2D array. Axes 0 and 1 of the output array correspond to Y and X axes of the image, respectively. The output image will have as many bands as the input; each output band has the same mask as the corresponding input band. The footprint and metadata of the input image are preserved.

UsageReturns
Image.neighborhoodToArray(kernel, defaultValue)Image
ArgumentTypeDetails
this: imageImageThe image to get pixels from; must be scalar-valued.
kernelKernelThe kernel specifying the shape of the neighborhood. Only fixed, square and rectangle kernels are supported. Weights are ignored; only the shape of the kernel is used.
defaultValueFloat, default: 0The value to use in the output arrays to replace the invalid (masked) pixels of the input. If the band type is integral, the fractional part of this value is discarded; in all cases, the value is clamped to the value range of the band.