geetools.ImageAccessor.distanceToMask#
- geetools.ImageAccessor.distanceToMask(mask, kernel='euclidean', radius=1000, band_name='distance_to_mask')#
Compute the distance from each pixel to the nearest non-masked pixel.
- Parameters:
mask (ee.Image) – The mask to compute the distance to.
kernel (str) – The kernel type to use for the distance computation default to “euclidean”.
radius (int) – The radius of the kernel.
band_name (geetools.types.ee_str) – The name of the band to store the distance values.
- Returns:
The original images with the distance band added.
- Return type:
ee.Image
Examples
import ee, geetools ee.Initialize() image = ee.Image('COPERNICUS/S2_SR/20190828T151811_20190828T151809_T18GYT') centerBuffer = image.geometry().centroid().buffer(100) BufferMask = ee.Image.constant(1).clip(centerBuffer) mask = ee.Image.constant(0).where(BufferMask, 1).clip(image.geometry()) image = image.distanceToMask(mask)