ee.Number.abs

Computes the absolute value of the input.

UsageReturns
Number.abs()Number
ArgumentTypeDetails
this: inputNumberThe input value.

Examples

Code Editor (JavaScript)

print('Absolute value of -1', ee.Number(-1).abs());  // 1
print('Absolute value of 0', ee.Number(0).abs());  // 0
print('Absolute value of 2.3', ee.Number(2.3).abs());  // 2.3

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)

print('Absolute value of -1:', ee.Number(-1).abs().getInfo())  # 1
print('Absolute value of 0:', ee.Number(0).abs().getInfo())  # 0
print('Absolute value of 2.3:', ee.Number(2.3).abs().getInfo())  # 2.3