Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.Array.eq

  • TheArray.eq method performs element-wise equality comparison between two arrays.

  • It returns 1 if the corresponding elements are equal and 0 otherwise.

  • The method handles different data types and floating-point comparisons, which can sometimes result in 0 even when values appear equal at first glance due to internal representation.

  • The method can be used with both JavaScript and Python implementations.

On an element-wise basis, returns 1 if and only if the first value is equal to the second.

UsageReturns
Array.eq(right)Array
ArgumentTypeDetails
this:leftArrayThe left-hand value.
rightArrayThe right-hand value.

Examples

Code Editor (JavaScript)

varempty=ee.Array([],ee.PixelType.int8());print(empty.eq(empty));// []print(ee.Array([0]).eq(ee.Array([1])));// 0print(ee.Array([0]).eq(ee.Array([0])));// 1print(ee.Array([1.1]).eq(ee.Array([1.1])));// 1print(ee.Array([1.1]).float().eq(ee.Array([1.1])));// 0print(ee.Array([1.1]).double().eq(ee.Array([1.1])));// 1print(ee.Array([1]).int8().eq(ee.Array([1])));// 1print(ee.Array([1]).int8().eq(ee.Array([1]).int32()));// 1

Python setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

empty=ee.Array([],ee.PixelType.int8())display(empty.eq(empty))# []display(ee.Array([0]).eq(ee.Array([1])))# 0display(ee.Array([0]).eq(ee.Array([0])))# 1display(ee.Array([1.1]).eq(ee.Array([1.1])))# 1display(ee.Array([1.1]).float().eq(ee.Array([1.1])))# 0display(ee.Array([1.1]).double().eq(ee.Array([1.1])))# 1display(ee.Array([1]).int8().eq(ee.Array([1])))# 1display(ee.Array([1]).int8().eq(ee.Array([1]).int32()))# 1

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-12-06 UTC.