ee.List.cat

  • List.cat() combines the elements of two lists into a new, single list, preserving the original order of elements.

  • It accepts two arguments: the initial list (this) and the list to append (other), both of type List.

  • The function returns a new List containing all elements from both input lists.

  • List.cat() handles empty lists gracefully, returning the non-empty list if one is empty, or an empty list if both are empty.

Concatenates the contents of other onto list.

UsageReturns
List.cat(other)List
ArgumentTypeDetails
this: listList
otherList

Examples

Code Editor (JavaScript)

print(ee.List(['dog']).cat(['squirrel']));  // ["dog","squirrel"]
print(ee.List(['moose']).cat(['&', 'squirrel']));  // ["moose","&","squirrel"]

print(ee.List([['a', 'b']]).cat(ee.List([['1', 1]])));  // [["a","b"],["1",1]]

print(ee.List([]).cat(ee.List([])));  // []
print(ee.List([1]).cat(ee.List([])));  // [1]
print(ee.List([]).cat(ee.List([2])));  // [2]

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)

print(ee.List(['dog']).cat(['squirrel']).getInfo())  # ['dog', 'squirrel']

# ['moose', '&', 'squirrel']
print(ee.List(['moose']).cat(['&', 'squirrel']).getInfo())

# [['a', 'b'], ['1', 1]]
print(ee.List([['a', 'b']]).cat(ee.List([['1', 1]])).getInfo())

print(ee.List([]).cat(ee.List([])).getInfo())  # []
print(ee.List([1]).cat(ee.List([])).getInfo())  # [1]
print(ee.List([]).cat(ee.List([2])).getInfo())  # [2]