ee.FeatureCollection.select

Wählen Sie Eigenschaften aus jedem Feature in einer Sammlung aus. Es ist auch möglich, diese Funktion nur mit Stringargumenten aufzurufen. Sie werden alle als „propertySelectors“ (Varargs) interpretiert.

Gibt die Sammlung von Features mit ausgewählten Attributen zurück.

NutzungAusgabe
FeatureCollection.select(propertySelectors, newProperties, retainGeometry)FeatureCollection
ArgumentTypDetails
So gehts: featurecollectionFeatureCollectionDie FeatureCollection-Instanz.
propertySelectorsList<String>Eine Liste mit Namen oder regulären Ausdrücken, die die auszuwählenden Attribute angeben.
newPropertiesList<String>, optionalEine Liste mit neuen Namen für die Ausgabeparameter. Muss mit der Anzahl der ausgewählten Properties übereinstimmen.
retainGeometryBoolesch, optionalWenn „false“, hat das Ergebnis eine NULL-Geometrie. Der Standardwert ist „true“.

Beispiele

Code-Editor (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());

Python einrichten

Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung finden Sie auf der Seite Python-Umgebung.

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())