ee.FeatureCollection.filter

  • The filter method is used to apply a filter to a collection.

  • The filter method returns the filtered collection.

  • The method takes a filter argument of type Filter .

  • Examples are provided in JavaScript and Python demonstrating how to use the filter method to select features based on an attribute value.

Apply a filter to this collection.

Returns the filtered collection.

Usage Returns
FeatureCollection. filter (filter) Collection
Argument Type Details
this: collection
Collection The Collection instance.
filter
Filter A filter to apply to this collection.

Examples

Code Editor (JavaScript)

 // Get Denver county polygon. 
 var 
  
 denver 
  
 = 
  
 ee 
 . 
 FeatureCollection 
 ( 
 'FAO/GAUL_SIMPLIFIED_500m/2015/level2' 
 ) 
  
 . 
 filter 
 ( 
 "ADM2_NAME == 'Denver'" 
 ) 
  
 . 
 filter 
 ( 
 ee 
 . 
 Filter 
 . 
 eq 
 ( 
 'ADM2_NAME' 
 , 
  
 'Denver' 
 )) 
  
 // Exactly the same as above. 
  
 . 
 first 
 () 
  
 . 
 geometry 
 (); 
 Map 
 . 
 centerObject 
 ( 
 denver 
 , 
  
 9 
 ); 
 Map 
 . 
 addLayer 
 ( 
 denver 
 , 
  
 null 
 , 
  
 'Denver' 
 ); 

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)

 # Get Denver county polygon. 
 denver 
 = 
 ( 
 ee 
 . 
 FeatureCollection 
 ( 
 'FAO/GAUL_SIMPLIFIED_500m/2015/level2' 
 ) 
 . 
 filter 
 ( 
 "ADM2_NAME == 'Denver'" 
 ) 
 . 
 filter 
 ( 
 ee 
 . 
 Filter 
 . 
 eq 
 ( 
 'ADM2_NAME' 
 , 
 'Denver' 
 )) 
 # Exactly the same as above. 
 . 
 first 
 () 
 . 
 geometry 
 () 
 ) 
 m 
 = 
 geemap 
 . 
 Map 
 () 
 m 
 . 
 center_object 
 ( 
 denver 
 , 
 9 
 ) 
 m 
 . 
 add_layer 
 ( 
 denver 
 , 
 None 
 , 
 'Denver' 
 ) 
 m 
Create a Mobile Website
View Site in Mobile | Classic
Share by: