Limit a collection to the specified number of elements, optionally sorting them by a specified property first.

Returns the limited collection.

FeatureCollection.limit(max, property, ascending)Collection
this: collectionCollection

The Collection instance.


The number to limit the collection to.

propertyString, optional

The property to sort by, if sorting.

ascendingBoolean, optional

Whether to sort in ascending or descending order. The default is true (ascending).


Code Editor (JavaScript)

// FeatureCollection of global power plants.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants');

print('First 5 features (power plants)', fc.limit(5));

print('Smallest 5 power plants by capacity in ascending order',
      fc.limit({max: 5, property: 'capacitymw'}));

print('Largest 5 power plants by capacity in descending order',
      fc.limit({max: 5, property: 'capacitymw', ascending: false}));