geetools.ImageAccessor.removeZeros#

geetools.ImageAccessor.removeZeros()#

Return an image array with non-zero values extracted from each band.

This function processes a multi-band image array, where each band represents different data. It removes zero values from each band independently and then combines the non-zero values from all bands into a single image. The resulting image may have inconsistent array lengths for each pixel, as the number of zero values removed can vary across bands.

Returns:

The image with the zero values removed from each band.

Return type:

ee.Image

Example

import ee, geetools

ee.Initialize()

vatican = ee.Geometry.Point([12.4534, 41.9033]).buffer(1)
image = ee.Image([0, 1, 2]).toArray()
image = image.geetools.removeZeros()
values = image.reduceRegion(ee.Reducer.first(), vatican, 1)
print(values.getInfo())