ee.Array.mask

Creates a subarray by slicing out each position in an input array that is parallel to a non-zero element of the given mask array.

UsageReturns
Array.mask(mask)Array
ArgumentTypeDetails
this: inputArray

Array to mask.

maskArray

Mask array.

Examples

JavaScript

print(ee.Array([1]).mask([0]));  // []
print(ee.Array([1]).mask([1]));  // [1]

print(ee.Array([0, 1, 2, 3]).mask([0, 4, -1, 1.2]));  // [1,2,3]

print(ee.Array([[1, 2, 3, 4]]).mask([[0, 0, 0, 0]]));  // [[]]
print(ee.Array([[1, 2, 3, 4]]).mask([[1, 0, 1, 1]]));  // [[1,3,4]]

var array = ee.Array([[1], [2], [3], [4]]);
print(array.mask([[0], [0], [0], [0]]));  // []
print(array.mask([[1], [0], [1], [1]]));  // [[1],[3],[4]]

var empty = ee.Array([], ee.PixelType.int8());
print(empty.mask(empty));  // []

Python

# Your example goes here!