ee.Image.where
Performs conditional replacement of values.
For each pixel in each band of 'input', if the corresponding pixel in 'test' is nonzero, output the corresponding pixel in value, otherwise output the input pixel.
If at a given pixel, either test or value is masked, the input value is used. If the input is masked, nothing is done.
The output bands have the same names as the input bands. The output type of each band is the larger of the input and value types. The output image retains the metadata and footprint of the input image.
Usage | Returns |
---|
Image.where(test, value) | Image |
Argument | Type | Details |
---|
this: input | Image | The input image. |
test | Image | The test image. The pixels of this image determines which of the input pixels is returned. If this is a single band, it is used for all bands in the input image. This may not be an array image. |
value | Image | The output value to use where test is not zero. If this is a single band, it is used for all bands in the input image. |
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 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["Replaces input image pixel values with values from a secondary image based on a test image's pixel values."],["If the test image pixel is non-zero, the corresponding pixel from the value image is used; otherwise, the original input pixel is retained."],["Input image metadata and footprint are preserved in the output image."],["Output image band types are determined by the larger type between the input and value images."],["Masked pixels in either test or value images result in the original input pixel being used in the output."]]],[]]