AI-generated Key Takeaways
-
The
ee.Array.identity(size)method creates a 2D identity matrix of a specified size. -
The
sizeargument 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.identityin JavaScript and Python, showing the output for various sizes including 0, 1, 2, and 3.
| 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));
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))