ee.Array.abs
On an element-wise basis, computes the absolute value of the input.
Usage | Returns |
---|
Array.abs() | Array |
Argument | Type | Details |
---|
this: input | Array | The input array. |
Examples
print(ee.Array([-1]).abs()); // [1]
print(ee.Array([-2, 0, 2]).abs()); // [2,0,2]
print(ee.Array([[-3.1, -2], [-1, 0]]).abs()); // [[3.1,2],[1,0]]
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
display(ee.Array([-1]).abs()) # [1]
display(ee.Array([-2, 0, 2]).abs()) # [2, 0, 2]
display(ee.Array([[-3.1, -2], [-1, 0]]).abs()) # [[3.1, 2], [1, 0]]
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."],[[["The `abs()` function calculates the absolute value of each element in an input array."],["It accepts an array as input and returns a new array with the absolute values of the original elements."],["The function works on arrays of any dimensions, including nested arrays."],["Both JavaScript and Python APIs support the `abs()` function."]]],["The `abs()` function computes the absolute value of each element in an input array. It takes an array as input (`this: input`) and returns a new array. The function operates element-wise, transforming negative values to their positive counterparts while leaving non-negative values unchanged. Examples show its use in JavaScript and Python, demonstrating its application to one-dimensional and two-dimensional arrays. In both cases it is used by the `.abs()` at the end of the array.\n"]]