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.identity

  • Theee.Array.identity(size) method creates a 2D identity matrix of a specified size.

  • Thesize argument is an integer that determines the length of each axis of the matrix.

  • The method returns an Earth Engine Array.

  • Examples demonstrate how to useee.Array.identity in JavaScript and Python, showing the output for various sizes including 0, 1, 2, and 3.

Creates a 2D identity matrix of the given size.

UsageReturns
ee.Array.identity(size)Array
ArgumentTypeDetails
sizeIntegerThe length of each axis.

Examples

Code Editor (JavaScript)

// []print(ee.Array.identity(0));// [[1]]print(ee.Array.identity(1));// [[1,0],//  [0,1]]print(ee.Array.identity(2));// [[1,0,0],//  [0,1,0],//  [0,0,1]]print(ee.Array.identity(3));

Python setup

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

importeeimportgeemap.coreasgeemap

Colab (Python)

# []display(ee.Array.identity(0))# [[1]]display(ee.Array.identity(1))# [[1, 0],#  [0, 1]]display(ee.Array.identity(2))# [[1, 0, 0],#  [0, 1, 0],#  [0, 0, 1]]display(ee.Array.identity(3))

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-10-06 UTC.