ee.FeatureCollection.limit

Limitez une collection au nombre d'éléments spécifié, en les triant éventuellement d'abord par une propriété spécifiée.

Renvoie la collection limitée.

UtilisationRenvoie
FeatureCollection.limit(max, property, ascending)Collection
ArgumentTypeDétails
ceci : collectionCollectionInstance de la collection.
maxNombreNombre maximal d'éléments de la collection.
propertyChaîne, facultativePropriété à utiliser pour le tri, le cas échéant.
ascendingBooléen, facultatifIndique si le tri doit être effectué par ordre croissant ou décroissant. La valeur par défaut est "true" (croissant).

Exemples

Éditeur de code (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}));

Configuration de Python

Consultez la page Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap pour le développement interactif.

import ee
import geemap.core as geemap

Colab (Python)

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

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

print('Smallest 5 power plants by capacity in ascending order:',
      fc.limit(**{'maximum': 5, 'opt_property': 'capacitymw'}).getInfo())

print('Largest 5 power plants by capacity in descending order:',
      fc.limit(**{'maximum': 5, 'opt_property': 'capacitymw',
                  'opt_ascending': False}).getInfo())