ee.FeatureCollection.select

Wybierz usługi z każdej funkcji w kolekcji. Można też wywołać tę funkcję tylko z argumentami w postaci ciągów znaków. Wszystkie będą interpretowane jako propertySelectors (varargs).

Zwraca kolekcję obiektów z wybranymi właściwościami.

WykorzystanieZwroty
FeatureCollection.select(propertySelectors, newProperties, retainGeometry)FeatureCollection
ArgumentTypSzczegóły
to: featurecollectionFeatureCollectionInstancja FeatureCollection.
propertySelectorsList<String>Lista nazw lub wyrażeń regularnych określających atrybuty do wybrania.
newPropertiesList<String>, opcjonalnieLista nowych nazw właściwości wyjściowych. Musi być zgodna z liczbą wybranych usług.
retainGeometryWartość logiczna, opcjonalnaJeśli ma wartość false, wynik będzie miał geometrię NULL. Domyślna wartość to true.

Przykłady

Edytor kodu (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());

Konfiguracja Pythona

Informacje o interfejsie Python API i używaniu geemap do interaktywnego programowania znajdziesz na stronie Środowisko Python.

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