ee.Image.reduceNeighborhood
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.
Usage | Returns |
---|
Image.reduceNeighborhood(reducer, kernel, inputWeight, skipMasked, optimization) | Image |
Argument | Type | Details |
---|
this: image | Image | The input image. |
reducer | Reducer | The reducer to apply to pixels within the neighborhood. |
kernel | Kernel | The kernel defining the neighborhood. |
inputWeight | String, default: "kernel" | One of 'mask', 'kernel', or 'min'. |
skipMasked | Boolean, default: true | Mask output pixels if the corresponding input pixel is masked. |
optimization | String, default: null | Optimization 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. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-13 UTC.
[null,null,["Last updated 2024-07-13 UTC."],[[["Applies a given reducer function to the neighborhood of each pixel, defined by a kernel."],["Output band names are determined by the reducer's output names, prefixed with the input band name for single-input reducers."],["Input weight for reducers can be based on the mask, kernel value, or the minimum of the two."],["Offers optimization strategies like 'boxcar' and 'window' for specific reducer and kernel types to improve performance."],["Allows skipping computation on masked pixels for efficiency."]]],["This operation applies a reducer to pixel neighborhoods defined by a kernel. The reducer can have single or multiple inputs, with output band names determined accordingly. Weighted inputs are supported based on the input mask, kernel value, or their minimum. Options are available to skip masked pixels and optimize the process. The `Image.reduceNeighborhood` function takes a reducer, kernel, input weight, skip masked option, and an optimization method, returning a new image.\n"]]