ee.FeatureCollection.select

בוחרים נכסים מכל תכונה באוסף. אפשר גם להפעיל את הפונקציה הזו רק עם ארגומנטים של מחרוזות. כל הארגומנטים יפורשו כ-propertySelectors (ארגומנטים משתנים).

הפונקציה מחזירה את אוסף התכונות עם המאפיינים שנבחרו.

שימושהחזרות
FeatureCollection.select(propertySelectors, newProperties, retainGeometry)FeatureCollection
ארגומנטסוגפרטים
זה: featurecollectionFeatureCollectionמופע FeatureCollection.
propertySelectorsList<String>רשימה של שמות או ביטויי Regular Expression שמציינים את המאפיינים שרוצים לבחור.
newProperties‫List<String>, אופציונלירשימה של שמות חדשים למאפייני הפלט. המספר הזה צריך להיות זהה למספר המאפיינים שנבחרו.
retainGeometryבוליאני, אופציונליאם הערך הוא false, התוצאה תכלול גיאומטריה מסוג NULL. ברירת המחדל היא True.

דוגמאות

עורך הקוד (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

מידע על Python API ועל שימוש ב-geemap לפיתוח אינטראקטיבי מופיע בדף Python Environment.

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