ee.FeatureCollection.size

  • The FeatureCollection.size() method returns the number of elements in a collection.

  • The method returns an Integer value.

  • It is applied to a FeatureCollection type object.

  • Examples in both JavaScript and Python demonstrate its usage to count features in a filtered collection.

Returns the number of elements in the collection.
Usage Returns
FeatureCollection. size () Integer
Argument Type Details
this: collection
FeatureCollection The collection to count.

Examples

Code Editor (JavaScript)

 // FeatureCollection of power plants in Belgium. 
 var 
  
 fc 
  
 = 
  
 ee 
 . 
 FeatureCollection 
 ( 
 'WRI/GPPD/power_plants' 
 ) 
  
 . 
 filter 
 ( 
 'country_lg == "Belgium"' 
 ); 
 print 
 ( 
 'Number of power plants in Belgium' 
 , 
  
 fc 
 . 
 size 
 ()); 

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"' 
 ) 
 display 
 ( 
 'Number of power plants in Belgium:' 
 , 
 fc 
 . 
 size 
 ()) 
Design a Mobile Site
View Site in Mobile | Classic
Share by: