On an element-wise basis, selects the first value if it is non-zero, and the second value otherwise.
Usage | Returns |
---|---|
Array.first_nonzero(right) | Array |
Argument | Type | Details |
---|---|---|
this: left | Array | The left-hand value. |
right | Array | The right-hand value. |
Examples
JavaScript
var empty = ee.Array([], ee.PixelType.int8()); print(empty.first_nonzero(empty)); // [] print(ee.Array([0]).first_nonzero(0)); // [0] print(ee.Array([0]).first_nonzero([0])); // [0] print(ee.Array([0]).first_nonzero([1])); // [1] print(ee.Array([2]).first_nonzero([3])); // [2] print(ee.Array([1]).first_nonzero([0])); // [1] print(ee.Array([-1, 0, 1]).first_nonzero([2, -1, 2])); // [-1,-1,1] // [[1,2],[3,4]] print(ee.Array([[1, 2], [0, 0]]).first_nonzero([[0, 0], [3, 4]]));
Python
# Your example goes here!