ee.FeatureCollection.makeArray

Fügen Sie jedem Feature in einer Sammlung ein eindimensionales Array hinzu, indem Sie eine Liste von Attributen für jedes Feature in einem eindimensionalen Array kombinieren. Alle Attribute müssen numerische Werte sein. Wenn ein Feature nicht alle benannten Attribute enthält oder eines der Attribute nicht numerisch ist, wird das Feature aus der resultierenden Sammlung entfernt.

NutzungAusgabe
FeatureCollection.makeArray(properties, name)FeatureCollection
ArgumentTypDetails
So gehts: collectionFeatureCollectionDie Eingabesammlung, aus der Attribute ausgewählt werden.
propertiesListeDie auszuwählenden Attribute.
nameString, Standard: „array“Der Name der neuen Array-Eigenschaft.

Beispiele

Code-Editor (JavaScript)

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

// A list of feature properties to combine into an array
// (power generation by year).
var properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016'];

// Add array of power-generation-by-year property to features.
fc = fc.makeArray(properties, 'gwh_by_year');

print('FeatureCollection with array of selected properties added', fc);
print('See example of new "gwh_by_year" property', fc.first().toDictionary());

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)

from pprint import pprint

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

# A list of feature properties to combine into an array
# (power generation by year).
properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016']

# Add array of power-generation-by-year property to features.
fc = fc.makeArray(properties, 'gwh_by_year')

print('FeatureCollection with array of selected properties added:',
      fc.getInfo())
print('See example of new "gwh_by_year" property:')
pprint(fc.first().toDictionary().getInfo())