ee.FeatureCollection.toList

  • The toList method returns the elements of a FeatureCollection as a list.

  • It can be used to fetch a specified number of elements and discard a number of elements from the start using the count and optional offset arguments.

  • Examples in JavaScript and Python demonstrate how to use the toList method to extract specific subsets of a FeatureCollection.

Returns the elements of a collection as a list.
Usage Returns
FeatureCollection. toList (count, offset ) List
Argument Type Details
this: collection
FeatureCollection The input collection to fetch.
count
Integer The maximum number of elements to fetch.
offset
Integer, default: 0 The number of elements to discard from the start. If set, (offset + count) elements will be fetched and the first offset elements will be discarded.

Examples

Code Editor (JavaScript)

 // FeatureCollection of power plants in Belgium. 
 var 
  
 fc 
  
 = 
  
 ee 
 . 
 FeatureCollection 
 ( 
 'WRI/GPPD/power_plants' 
 ) 
  
 . 
 filter 
 ( 
 'country_lg == "Belgium"' 
 ); 
 print 
 ( 
 'First 5 features to an ee.List' 
 , 
  
 fc 
 . 
 toList 
 ( 
 5 
 )); 
 print 
 ( 
 'Second 5 features to an ee.List' 
 , 
  
 fc 
 . 
 toList 
 ( 
 5 
 , 
  
 5 
 )); 

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 
 ( 
 'First 5 features to an ee.List:' 
 , 
 fc 
 . 
 toList 
 ( 
 5 
 )) 
 display 
 ( 
 'Second 5 features to an ee.List:' 
 , 
 fc 
 . 
 toList 
 ( 
 5 
 , 
 5 
 )) 
Create a Mobile Website
View Site in Mobile | Classic
Share by: