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.first Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
Array.firstmethod selects the value of the first element on an element-wise basis.It takes a right-hand array or a single value as an argument and returns an Array.
Both the left-hand and right-hand values are expected to be Arrays.
| Usage | Returns |
|---|---|
Array.first(right) | Array |
| Argument | Type | Details |
|---|---|---|
this:left | Array | The left-hand value. |
right | Array | The right-hand value. |
Examples
Code Editor (JavaScript)
varempty=ee.Array([],ee.PixelType.int8());print(empty.first(empty));// []print(ee.Array([0]).first(0));// [0]print(ee.Array([0,1,2]).first(1));// [0,1,2]print(ee.Array([0,1,2]).first(ee.Array([3,4,5])));// [0,1,2]print(ee.Array([3,4,5]).first(ee.Array([0,1,2])));// [3,4,5]
Python setup
See the Python Environment page for information on the Python API and usinggeemap for interactive development.
importeeimportgeemap.coreasgeemap
Colab (Python)
empty=ee.Array([],ee.PixelType.int8())display(empty.first(empty))# []display(ee.Array([0]).first(0))# [0]display(ee.Array([0,1,2]).first(1))# [0,1,2]display(ee.Array([0,1,2]).first(ee.Array([3,4,5])))# [0, 1, 2]display(ee.Array([3,4,5]).first(ee.Array([0,1,2])))# [3, 4, 5]
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.