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

  • Theee.Array() function returns an array with given coordinate values.

  • Thevalues argument can be an existing array, a number, a list of numbers, or a nested list of numbers.

  • ThepixelType argument specifies the type of each number in the array, and if not provided, it will be inferred from thevalues.

  • ee.Array can create empty arrays, 1-D arrays, and 2-D arrays.

  • Arrays can be constructed fromee.Number objects oree.List sequences.

Returns an array with the given coordinates.

UsageReturns
ee.Array(values,pixelType)Array
ArgumentTypeDetails
valuesObjectAn existing array to cast, or a number/list of numbers/nested list of numbers of any depth to create an array from. For nested lists, all inner arrays at the same depth must have the same length and numbers may only be present at the deepest level.
pixelTypePixelType, default: nullThe type of each number in the values argument. If the pixel type is not provided, it will be inferred from the numbers in 'values'. If there aren't any numbers in 'values', this type must be provided.

Examples

Code Editor (JavaScript)

// Requires an explicit PixelType if no data.print(ee.Array([],ee.PixelType.int8()));// Empty []print(ee.Array([[]],ee.PixelType.uint8()));// Empty [[]]print(ee.Array([[],[]],ee.PixelType.float()));// Empty [[], []]// 1-D Arraysprint(ee.Array([0]));// [0]print(ee.Array([0,1]));// [0, 1]// 2-D Arraysprint(ee.Array([[1]]));// [[1]]print(ee.Array([[0,1],[2,3]]));// [[0,1],[2,3]]// Arrays from ee.Number.print(ee.Array([ee.Number(123).toUint8()]));// [123]// Lists are useful ways to construct larger Arrays.print(ee.Array(ee.List.sequence(0,10,2)));// [0,2,4,6,8,10]// Arrays can be used to make Arrays.vararray1D=ee.Array([1,2,3]);// This is a cast.print(ee.Array(array1D));// [1,2,3]

Python setup

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

importeeimportgeemap.coreasgeemap

Colab (Python)

# Requires an explicit PixelType if no data.display(ee.Array([],ee.PixelType.int8()))# Empty []display(ee.Array([[]],ee.PixelType.uint8()))# Empty [[]]display(ee.Array([[],[]],ee.PixelType.float()))# Empty [[], []]# 1-D Arraysdisplay(ee.Array([0]))# [0]display(ee.Array([0,1]))# [0, 1]# 2-D Arraysdisplay(ee.Array([[1]]))# [[1]]display(ee.Array([[0,1],[2,3]]))# [[0,1],[2,3]]# Arrays from ee.Number.display(ee.Array([ee.Number(123).toUint8()]))# [123]# Lists are useful ways to construct larger Arrays.display(ee.Array(ee.List.sequence(0,10,2)))# [0, 2, 4, 6, 8, 10]# Arrays can be used to make Arrays.array_one=ee.Array([1,2,3])# This is a cast.display(ee.Array(array_one))# [1, 2, 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 2024-07-13 UTC.