ee.Image.reduceNeighborhood

  • The reduceNeighborhood function applies a reducer to the neighborhood of each pixel using a specified kernel.

  • The reducer's input requirements depend on whether it's a single-input or multi-input reducer.

  • Output band names are determined by the reducer's output names, with single-input reducers prefixing input band names.

  • Reducers with weighted inputs can use the input mask, kernel value, or the minimum of the two for weighting.

Applies the given reducer to the neighborhood around each pixel, as determined by the given kernel. If the reducer has a single input, it will be applied separately to each band of the collection; otherwise it must have the same number of inputs as the input image has bands.

The reducer output names determine the names of the output bands: reducers with multiple inputs will use the output names directly, while reducers with a single input will prefix the output name with the input band name (e.g., '10_mean', '20_mean').

Reducers with weighted inputs can have the input weight based on the input mask, the kernel value, or the smaller of those two.

UsageReturns
Image.reduceNeighborhood(reducer, kernel, inputWeight, skipMasked, optimization)Image
ArgumentTypeDetails
this: imageImageThe input image.
reducerReducerThe reducer to apply to pixels within the neighborhood.
kernelKernelThe kernel defining the neighborhood.
inputWeightString, default: "kernel"One of 'mask', 'kernel', or 'min'.
skipMaskedBoolean, default: trueMask output pixels if the corresponding input pixel is masked.
optimizationString, default: nullOptimization strategy. Options are 'boxcar' and 'window'. The 'boxcar' method is a fast method for computing count, sum or mean. It requires a homogeneous kernel, a single-input reducer and either MASK, KERNEL or no weighting. The 'window' method uses a running window, and has the same requirements as 'boxcar', but can use any single input reducer. Both methods require considerable additional memory.