ee.FeatureCollection.select

Select properties from each Feature in a collection. It is also possible to call this function with only string arguments; they will be all be interpreted as propertySelectors (varargs).

Returns the feature collection with selected properties.

Usage Returns
FeatureCollection. select (propertySelectors, newProperties , retainGeometry ) FeatureCollection
Argument Type Details
this: featurecollection
FeatureCollection The FeatureCollection instance.
propertySelectors
List<String> A list of names or regexes specifying the attributes to select.
newProperties
List<String>, optional A list of new names for the output properties. Must match the number of properties selected.
retainGeometry
Boolean, optional When false, the result will have a NULL geometry. Defaults to true.

Examples

Code Editor (JavaScript)

 // FeatureCollection of power plants in Belgium. 
 var 
  
 fc 
  
 = 
  
 ee 
 . 
 FeatureCollection 
 ( 
 'WRI/GPPD/power_plants' 
 ) 
  
 . 
 filter 
 ( 
 'country_lg == "Belgium"' 
 ); 
 // Select a single property. 
 var 
  
 singleProp 
  
 = 
  
 fc 
 . 
 select 
 ( 
 'fuel1' 
 ); 
 print 
 ( 
 'Single property selected' 
 , 
  
 singleProp 
 . 
 first 
 ()); 
 // Select multiple properties. 
 var 
  
 multiProp 
  
 = 
  
 fc 
 . 
 select 
 ([ 
 'fuel1' 
 , 
  
 'capacitymw' 
 ]); 
 print 
 ( 
 'Multiple properties selected' 
 , 
  
 multiProp 
 . 
 first 
 ()); 
 // Select multiple properties and rename them. 
 var 
  
 multiPropRename 
  
 = 
  
 fc 
 . 
 select 
 ({ 
  
 propertySelectors 
 : 
  
 [ 
 'fuel1' 
 , 
  
 'capacitymw' 
 ], 
  
 newProperties 
 : 
  
 [ 
 'Fuel_1' 
 , 
  
 'Capacity_MW' 
 ] 
 }); 
 print 
 ( 
 'Multiple properties selected, renamed' 
 , 
  
 multiPropRename 
 . 
 first 
 ()); 
 // Select multiple properties, remove geometry. 
 var 
  
 multiPropNoGeom 
  
 = 
  
 fc 
 . 
 select 
 ({ 
  
 propertySelectors 
 : 
  
 [ 
 'fuel1' 
 , 
  
 'capacitymw' 
 ], 
  
 retainGeometry 
 : 
  
 false 
 }); 
 print 
 ( 
 'Multiple properties selected, geometry removed' 
 , 
  
 multiPropNoGeom 
 . 
 first 
 ()); 

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)

 # FeatureCollection of power plants in Belgium. 
 fc 
 = 
 ee 
 . 
 FeatureCollection 
 ( 
 'WRI/GPPD/power_plants' 
 ) 
 . 
 filter 
 ( 
 'country_lg == "Belgium"' 
 ) 
 # Select a single property. 
 single_prop 
 = 
 fc 
 . 
 select 
 ( 
 'fuel1' 
 ) 
 print 
 ( 
 'Single property selected:' 
 , 
 single_prop 
 . 
 first 
 () 
 . 
 getInfo 
 ()) 
 # Select multiple properties. 
 multi_prop 
 = 
 fc 
 . 
 select 
 ([ 
 'fuel1' 
 , 
 'capacitymw' 
 ]) 
 print 
 ( 
 'Multiple properties selected:' 
 , 
 multi_prop 
 . 
 first 
 () 
 . 
 getInfo 
 ()) 
 # Select multiple properties and rename them. 
 multi_prop_rename 
 = 
 fc 
 . 
 select 
 ( 
 ** 
 { 
 'propertySelectors' 
 : 
 [ 
 'fuel1' 
 , 
 'capacitymw' 
 ], 
 'newProperties' 
 : 
 [ 
 'Fuel_1' 
 , 
 'Capacity_MW' 
 ] 
 }) 
 print 
 ( 
 'Multiple properties selected, renamed:' 
 , 
 multi_prop_rename 
 . 
 first 
 () 
 . 
 getInfo 
 ()) 
 # Select multiple properties, remove geometry. 
 multi_prop_no_geom 
 = 
 fc 
 . 
 select 
 ( 
 ** 
 { 
 'propertySelectors' 
 : 
 [ 
 'fuel1' 
 , 
 'capacitymw' 
 ], 
 'retainGeometry' 
 : 
 False 
 }) 
 print 
 ( 
 'Multiple properties selected, geometry removed:' 
 , 
 multi_prop_no_geom 
 . 
 first 
 () 
 . 
 getInfo 
 ()) 
Create a Mobile Website
View Site in Mobile | Classic
Share by: