Filtering a FeatureCollection

Filtering a FeatureCollection is analogous to filtering an ImageCollection. (See the Filtering an ImageCollection section). There are the featureCollection.filterDate(), and featureCollection.filterBounds() convenience methods and the featureCollection.filter() method for use with any applicable ee.Filter. For example:

// Load watersheds from a Fusion Table.
var sheds = ee.FeatureCollection('ft:1IXfrLpTHX4dtdj1LcNXjJADBB-d93rkdJ9acSEWK');

// Define a region roughly covering the continental US.
var continentalUS = ee.Geometry.Rectangle(-127.18, 19.39, -62.75, 51.29);

// Filter the table geographically: only watersheds in the continental US.
var filtered = sheds.filterBounds(continentalUS);

// Check the number of watersheds after filtering for location.
print('Count after filter:', filtered.size());

// Filter to get only larger continental US watersheds.
var largeSheds = filtered.filter(ee.Filter.gt('AreaSqKm', 25000));

// Check the number of watersheds after filtering for size and location.
print('Count after filtering by size:', largeSheds.size());
    

Send feedback about...

Google Earth Engine API