ee.FeatureCollection.select

เลือกพร็อพเพอร์ตี้จากแต่ละฟีเจอร์ในคอลเล็กชัน นอกจากนี้ คุณยังเรียกฟังก์ชันนี้ด้วยอาร์กิวเมนต์สตริงเท่านั้นได้ โดยระบบจะตีความอาร์กิวเมนต์ทั้งหมดเป็น propertySelectors (varargs)

แสดงผลคอลเล็กชันฟีเจอร์ที่มีพร็อพเพอร์ตี้ที่เลือก

การใช้งานการคืนสินค้า
FeatureCollection.select(propertySelectors, newProperties, retainGeometry)FeatureCollection
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ featurecollectionFeatureCollectionอินสแตนซ์ FeatureCollection
propertySelectorsList<String>รายการชื่อหรือนิพจน์ทั่วไปที่ระบุแอตทริบิวต์ที่จะเลือก
newPropertiesList<String> ไม่บังคับรายการชื่อใหม่สำหรับพร็อพเพอร์ตี้เอาต์พุต ต้องตรงกับจำนวนพร็อพเพอร์ตี้ที่เลือก
retainGeometryบูลีน ไม่บังคับหากเป็นเท็จ ผลลัพธ์จะมีเรขาคณิตเป็น 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

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