ee.FeatureCollection.limit

Giới hạn một tập hợp ở số lượng phần tử đã chỉ định, bạn cũng có thể sắp xếp các phần tử theo một thuộc tính đã chỉ định trước.

Trả về tập hợp có giới hạn.

Cách sử dụngGiá trị trả về
FeatureCollection.limit(max, property, ascending)Bộ sưu tập
Đối sốLoạiThông tin chi tiết
this: collectionBộ sưu tậpPhiên bản Bộ sưu tập.
maxSốSố lượng để giới hạn bộ sưu tập.
propertyChuỗi, không bắt buộcThuộc tính để sắp xếp theo (nếu sắp xếp).
ascendingBoolean, không bắt buộcCó sắp xếp theo thứ tự tăng dần hay giảm dần hay không. Giá trị mặc định là true (tăng dần).

Ví dụ

Trình soạn thảo mã (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}));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

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