ee.Number.or

  • Number.or() is a function that returns 1 if either the left or right input is non-zero, otherwise it returns 0.

  • It takes two Number type arguments: left representing the left-hand value and right representing the right-hand value.

  • This function can be effectively used to check for the presence of non-zero values within Earth Engine computations.

Returns 1 if and only if either input value is non-zero.

UsageReturns
Number.or(right)Number
ArgumentTypeDetails
this: leftNumberThe left-hand value.
rightNumberThe right-hand value.

Examples

Code Editor (JavaScript)

print('Either 0 or 5 non-zero?', ee.Number(0).or(ee.Number(5)));  // 1
print('Either 0 or 0 non-zero?', ee.Number(0).or(ee.Number(0)));  // 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

Colab (Python)

print('Either 0 or 5 non-zero?', ee.Number(0).Or(ee.Number(5)).getInfo())  # 1
print('Either 0 or 0 non-zero?', ee.Number(0).Or(ee.Number(0)).getInfo())  # 0