ee.FeatureCollection.makeArray

Thêm một mảng 1 chiều vào từng đối tượng trong một tập hợp bằng cách kết hợp danh sách các thuộc tính cho từng đối tượng thành một mảng 1 chiều. Tất cả các thuộc tính phải là giá trị số. Nếu một đối tượng không chứa tất cả các thuộc tính được đặt tên hoặc bất kỳ thuộc tính nào trong số đó không phải là thuộc tính dạng số, thì đối tượng đó sẽ bị loại bỏ khỏi tập hợp kết quả.

Cách sử dụngGiá trị trả về
FeatureCollection.makeArray(properties, name)FeatureCollection
Đối sốLoạiThông tin chi tiết
this: collectionFeatureCollectionTập hợp đầu vào mà từ đó các thuộc tính sẽ được chọn.
propertiesDanh sáchCác thuộc tính cần chọn.
nameChuỗi, mặc định: "array"Tên của thuộc tính mảng mới.

Ví dụ

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

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)

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