AI-generated Key Takeaways
-
The
subtractmethod performs element-wise subtraction between two values. -
It takes two Array inputs, a left-hand value (
this) and a right-hand value (right). -
The method returns a new Array containing the results of the subtraction.
-
The
subtractmethod can handle both scalar and array subtraction. -
The examples demonstrate subtraction with single-element arrays, multi-element arrays, and empty arrays.
| Usage | Returns |
|---|---|
Array.subtract(right) | Array |
| Argument | Type | Details |
|---|---|---|
this: left | Array | The left-hand value. |
right | Array | The right-hand value. |
Examples
Code Editor (JavaScript)
print(ee.Array([10]).subtract(1)); // [9] print(ee.Array([-1, 0, 1]).subtract(2)); // [-3,-2,-1] print(ee.Array([-1, 0, 1]).subtract([-5, 6, 7])); // [4,-6,-6] var empty = ee.Array([], ee.PixelType.int8()); print(empty.subtract(empty)); // []
import ee import geemap.core as geemap
Colab (Python)
display(ee.Array([10]).subtract(1)) # [9] display(ee.Array([-1, 0, 1]).subtract(2)) # [-3, -2, -1] display(ee.Array([-1, 0, 1]).subtract([-5, 6, 7])) # [4, -6, -6] empty = ee.Array([], ee.PixelType.int8()) display(empty.subtract(empty)) # []