ee.Array.add
On an element-wise basis, adds the first value to the second.
Usage | Returns |
---|
Array.add(right) | Array |
Argument | Type | Details |
---|
this: left | Array | The left-hand value. |
right | Array | The right-hand value. |
Examples
var empty = ee.Array([], ee.PixelType.int8());
print(empty.add(empty)); // []
print(ee.Array([0]).add(1)); // [1]
print(ee.Array([1]).add([2])); // [3]
print(ee.Array([-3]).add([-4])); // [-7]
print(ee.Array([5, 6]).add([7, 8])); // [12,14]
var array2x3 = ee.Array([[0, 1, 2], [3, 4, 5]]);
print(array2x3.add(1)); // [[1,2,3],[4,5,6]]
print(array2x3.add(array2x3)); // [[0,2,4],[6,8,10]]
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
empty = ee.Array([], ee.PixelType.int8())
display(empty.add(empty)) # []
display(ee.Array([0]).add(1)) # [1]
display(ee.Array([1]).add([2])) # [3]
display(ee.Array([-3]).add([-4])) # [-7]
display(ee.Array([5, 6]).add([7, 8])) # [12 ,14]
array2x3 = ee.Array([[0, 1, 2], [3, 4, 5]])
display(array2x3.add(1)) # [[1, 2 ,3], [4, 5, 6]]
display(array2x3.add(array2x3)) # [[0, 2, 4], [6, 8, 10]]
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.add()` performs element-wise addition, adding the corresponding elements of two arrays or an array and a scalar."],["The method returns a new array with the results of the addition."],["It supports both single values and multi-dimensional arrays as input."],["`Array.add()` can be used with both server-side objects (like Images) and client-side objects (like Lists)."]]],["The `Array.add(right)` function performs element-wise addition between two arrays. The left-hand array is added to the right-hand array or value, returning a new array. It supports adding a scalar value to an array or adding two arrays of the same dimensions. Examples show how an empty array added to itself returns an empty array, single element arrays added to a scalar or array, as well as multi-element and multi-dimensional array addition.\n"]]