ee.FeatureCollection.select

Sélectionnez des propriétés pour chaque entité d'une collection. Il est également possible d'appeler cette fonction avec uniquement des arguments de chaîne. Ils seront tous interprétés comme des propertySelectors (varargs).

Renvoie la collection d'entités avec les propriétés sélectionnées.

UtilisationRenvoie
FeatureCollection.select(propertySelectors, newProperties, retainGeometry)FeatureCollection
ArgumentTypeDétails
ceci : featurecollectionFeatureCollectionInstance FeatureCollection.
propertySelectorsList<String>Liste de noms ou d'expressions régulières spécifiant les attributs à sélectionner.
newPropertiesList<String>, facultatifListe des nouveaux noms des propriétés de sortie. Doit correspondre au nombre de propriétés sélectionnées.
retainGeometryBooléen, facultatifSi la valeur est "false", le résultat aura une géométrie NULL. La valeur par défaut est "true".

Exemples

Éditeur de code (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
            .filter('country_lg == "Belgium"');

// Select a single property.
var singleProp = fc.select('fuel1');
print('Single property selected',
      singleProp.first());

// Select multiple properties.
var multiProp = fc.select(['fuel1', 'capacitymw']);
print('Multiple properties selected',
      multiProp.first());

// Select multiple properties and rename them.
var multiPropRename = fc.select({
  propertySelectors: ['fuel1', 'capacitymw'],
  newProperties: ['Fuel_1', 'Capacity_MW']
});
print('Multiple properties selected, renamed',
      multiPropRename.first());

// Select multiple properties, remove geometry.
var multiPropNoGeom = fc.select({
  propertySelectors: ['fuel1', 'capacitymw'],
  retainGeometry: false
});
print('Multiple properties selected, geometry removed',
      multiPropNoGeom.first());

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 power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')

# Select a single property.
single_prop = fc.select('fuel1')
print('Single property selected:', single_prop.first().getInfo())

# Select multiple properties.
multi_prop = fc.select(['fuel1', 'capacitymw'])
print('Multiple properties selected:', multi_prop.first().getInfo())

# Select multiple properties and rename them.
multi_prop_rename = fc.select(**{
    'propertySelectors': ['fuel1', 'capacitymw'],
    'newProperties': ['Fuel_1', 'Capacity_MW']
    })
print('Multiple properties selected, renamed:',
      multi_prop_rename.first().getInfo())

# Select multiple properties, remove geometry.
multi_prop_no_geom = fc.select(**{
    'propertySelectors': ['fuel1', 'capacitymw'],
    'retainGeometry': False
    })
print('Multiple properties selected, geometry removed:',
      multi_prop_no_geom.first().getInfo())