ee.List.add

  • The add method appends an element to the end of a list.

  • The add method can append various data types including strings, numbers, booleans, lists, dictionaries, images, and image collections.

  • The add method returns the modified list.

  • Examples in both JavaScript and Python demonstrate the functionality of the add method with different input types.

Appends the element to the end of list.
Usage Returns
List. add (element) List
Argument Type Details
this: list
List
element
Object

Examples

Code Editor (JavaScript)

 print 
 ( 
 ee 
 . 
 List 
 ([]). 
 add 
 ( 
 'b' 
 )); 
  
 // ["b"] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 'b' 
 )); 
  
 // ["a","b"] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 String 
 ( 
 'b' 
 ))); 
  
 // ["a","b"] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 1 
 )); 
  
 // ["a",1] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 Number 
 ( 
 1 
 ))); 
  
 // ["a",1] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 true 
 )); 
  
 // ["a",true] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ([])); 
  
 // ["a",[]] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 List 
 ([]))); 
  
 // ["a",[]] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ([ 
 'b' 
 ])); 
  
 // ["a",["b"]] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 List 
 ([ 
 'b' 
 ]))); 
  
 // ["a",["b"]] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 Dictionary 
 ())); 
  
 // ["a",{}] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 Dictionary 
 ({ 
 b 
 : 
  
 'c' 
 }))); 
  
 // ["a",{"b":"c"}] 
 // 0: a 
 // 1: Image (1 band) 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 Image 
 . 
 constant 
 ( 
 1 
 ))); 
 // ["a",{"type":"ImageCollection","bands":[]}] 
 print 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]). 
 add 
 ( 
 ee 
 . 
 ImageCollection 
 ([]))); 

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 
 . 
 List 
 ([]) 
 . 
 add 
 ( 
 'b' 
 )) 
 # ['b'] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 'b' 
 )) 
 # ['a', 'b'] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 String 
 ( 
 'b' 
 ))) 
 # ['a', 'b'] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 1 
 )) 
 # ['a', 1] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 Number 
 ( 
 1 
 ))) 
 # ['a', 1] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 True 
 )) 
 # ['a', True] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ([])) 
 # ['a', []] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 List 
 ([]))) 
 # ['a', []] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ([ 
 'b' 
 ])) 
 # ['a', ['b']] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 List 
 ([ 
 'b' 
 ]))) 
 # ['a', ['b']] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 Dictionary 
 ())) 
 # ['a', {}] 
 # ['a', {'b': 'c'}] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 Dictionary 
 ({ 
 'b' 
 : 
 'c' 
 }))) 
 # 0: a 
 # 1: Image (1 band) 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 Image 
 . 
 constant 
 ( 
 1 
 ))) 
 # ["a", {"type":"ImageCollection", "bands":[]}] 
 display 
 ( 
 ee 
 . 
 List 
 ([ 
 'a' 
 ]) 
 . 
 add 
 ( 
 ee 
 . 
 ImageCollection 
 ([]))) 
Design a Mobile Site
View Site in Mobile | Classic
Share by: