ee.FeatureCollection.limit

จำกัดคอลเล็กชันให้มีจำนวนองค์ประกอบตามที่ระบุ โดยอาจจัดเรียงตามพร็อพเพอร์ตี้ที่ระบุก่อนก็ได้

แสดงผลคอลเล็กชันที่จำกัด

การใช้งานการคืนสินค้า
FeatureCollection.limit(max, property, ascending)คอลเล็กชัน
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ collectionคอลเล็กชันอินสแตนซ์คอลเล็กชัน
maxตัวเลขจำนวนที่จะจำกัดคอลเล็กชัน
propertyสตริง ไม่บังคับพร็อพเพอร์ตี้ที่จะใช้เรียงลำดับ หากมีการเรียงลำดับ
ascendingบูลีน ไม่บังคับเลือกว่าจะจัดเรียงจากน้อยไปมากหรือมากไปน้อย ค่าเริ่มต้นคือ True (จากน้อยไปมาก)

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (JavaScript)

// FeatureCollection of global power plants.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants');

print('First 5 features (power plants)', fc.limit(5));

print('Smallest 5 power plants by capacity in ascending order',
      fc.limit({max: 5, property: 'capacitymw'}));

print('Largest 5 power plants by capacity in descending order',
      fc.limit({max: 5, property: 'capacitymw', ascending: false}));

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

import ee
import geemap.core as geemap

Colab (Python)

# FeatureCollection of global power plants.
fc = ee.FeatureCollection('WRI/GPPD/power_plants')

print('First 5 features (power plants):', fc.limit(5).getInfo())

print('Smallest 5 power plants by capacity in ascending order:',
      fc.limit(**{'maximum': 5, 'opt_property': 'capacitymw'}).getInfo())

print('Largest 5 power plants by capacity in descending order:',
      fc.limit(**{'maximum': 5, 'opt_property': 'capacitymw',
                  'opt_ascending': False}).getInfo())