ee.Array.identity

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 using geemap for interactive development.

import ee
import geemap.core as geemap

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))