ee.Array.identity

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

  • The size 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 use ee.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.
Usage Returns
ee.Array.identity(size) Array
Argument Type Details
size
Integer The 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 
 )) 
Design a Mobile Site
View Site in Mobile | Classic
Share by: