ee.FeatureCollection.set

  • The set method overrides one or more metadata properties of an Element.

  • The set method returns the element with the specified properties overridden.

  • The set method accepts either a dictionary of properties or a vararg sequence of properties as input.

  • The examples show how to set single, multiple, and nested properties, as well as how to overwrite existing properties.

Overrides one or more metadata properties of an Element.

Returns the element with the specified properties overridden.

Usage Returns
FeatureCollection. set (var_args) Element
Argument Type Details
this: element
Element The Element instance.
var_args
VarArgs<Object> Either a dictionary of properties, or a vararg sequence of properties, e.g. key1, value1, key2, value2, ...

Examples

Code Editor (JavaScript)

 // An empty FeatureCollection for simple demonstration. 
 var 
  
 fc 
  
 = 
  
 ee 
 . 
 FeatureCollection 
 ([]); 
 // Set a single new property using a key-value pair. 
 fc 
  
 = 
  
 fc 
 . 
 set 
 ( 
 'key_1' 
 , 
  
 'value 1' 
 ); 
 // Set multiple new properties using a series of key-value pairs. 
 fc 
  
 = 
  
 fc 
 . 
 set 
 ( 
 'key_2' 
 , 
  
 'value 2' 
 , 
  
 'key_3' 
 , 
  
 3 
 ); 
 // Set new properties using a dictionary of key-value pairs. 
 fc 
  
 = 
  
 fc 
 . 
 set 
 ({ 
  
 key_5 
 : 
  
 ee 
 . 
 Array 
 ([ 
 1 
 , 
  
 2 
 , 
  
 3 
 ]), 
  
 key_6 
 : 
  
 ee 
 . 
 Image 
 ( 
 0 
 ), 
  
 key_7 
 : 
  
 ee 
 . 
 Feature 
 ( 
 null 
 ) 
 }); 
 print 
 ( 
 'New FeatureCollection properties added' 
 , 
  
 fc 
 ); 
 // Overwrite an existing property. 
 fc 
  
 = 
  
 fc 
 . 
 set 
 ( 
 'key_1' 
 , 
  
 'overwritten' 
 ); 
 print 
 ( 
 'FeatureCollection property overwritten' 
 , 
  
 fc 
 ); 

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)

 # An empty FeatureCollection for simple demonstration. 
 fc 
 = 
 ee 
 . 
 FeatureCollection 
 ([]) 
 # Set a single new property using a key-value pair. 
 fc 
 = 
 fc 
 . 
 set 
 ( 
 'key_1' 
 , 
 'value 1' 
 ) 
 # Set multiple new properties using a series of key-value pairs. 
 fc 
 = 
 fc 
 . 
 set 
 ( 
 'key_2' 
 , 
 'value 2' 
 , 
 'key_3' 
 , 
 3 
 ) 
 # Set new properties using a dictionary of key-value pairs. 
 fc 
 = 
 fc 
 . 
 set 
 ({ 
 'key_5' 
 : 
 ee 
 . 
 Array 
 ([ 
 1 
 , 
 2 
 , 
 3 
 ]), 
 'key_6' 
 : 
 ee 
 . 
 Image 
 ( 
 0 
 ), 
 'key_7' 
 : 
 ee 
 . 
 Feature 
 ( 
 None 
 ) 
 }) 
 display 
 ( 
 'New FeatureCollection properties added:' 
 , 
 fc 
 ) 
 # Overwrite an existing property. 
 fc 
 = 
 fc 
 . 
 set 
 ( 
 'key_1' 
 , 
 'overwritten' 
 ) 
 display 
 ( 
 'FeatureCollection property overwritten:' 
 , 
 fc 
 ) 
Create a Mobile Website
View Site in Mobile | Classic
Share by: