ee.Array.subtract
On an element-wise basis, subtracts the second value from the first.
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)); // []
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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)) # []
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["`Array.subtract()` subtracts the elements of a second array from the corresponding elements of the first array, returning a new array with the results."],["It supports element-wise subtraction between two arrays or between an array and a scalar value."],["If the arrays have different lengths or dimensions, the behavior is undefined and may lead to errors."],["An empty array subtracted from itself returns an empty array."]]],[]]