ee.FeatureCollection.getInfo

Một hàm bắt buộc trả về tất cả thông tin đã biết về bộ sưu tập này thông qua lệnh gọi AJAX.

Trả về nội dung mô tả bộ sưu tập có các trường sau:

  – features: danh sách chứa siêu dữ liệu về các đối tượng trong bộ sưu tập.

  - properties: một từ điển không bắt buộc chứa các thuộc tính siêu dữ liệu của bộ sưu tập.

Cách sử dụngGiá trị trả về
FeatureCollection.getInfo(callback)FeatureCollectionDescription
Đối sốLoạiThông tin chi tiết
this: featurecollectionFeatureCollectionĐối tượng FeatureCollection.
callbackHàm, không bắt buộcMột lệnh gọi lại không bắt buộc. Nếu không được cung cấp, lệnh gọi sẽ được thực hiện đồng bộ. Nếu được cung cấp, sẽ được gọi bằng tham số đầu tiên nếu thành công và tham số thứ hai nếu không thành công.

Ví dụ

Trình soạn thảo mã (JavaScript)

/**
 * WARNING: this function transfers data from Earth Engine servers to the
 * client. Doing so can negatively affect request processing and client
 * performance. Server-side options should be used whenever possible.
 * Learn more about the distinction between server and client:
 * https://developers.google.com/earth-engine/guides/client_server
 */

// A server-side ee.FeatureCollection of power plants in Belgium.
var fcServer = ee.FeatureCollection('WRI/GPPD/power_plants')
             .filter('country_lg == "Belgium"');

// Use getInfo to transfer server-side feature collection to the client. The
// result is an object.
var fcClient = fcServer.getInfo();
print('Client-side feature collection is an object', typeof fcClient);
print('Feature collection object keys', Object.keys(fcClient));
print('Array of features', fcClient.features);
print('Properties of first feature', fcClient.features[0].properties);

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)

"""WARNING: this function transfers data from Earth Engine servers to the
client. Doing so can negatively affect request processing and client
performance. Server-side options should be used whenever possible.
Learn more about the distinction between server and client:
https://developers.google.com/earth-engine/guides/client_server
"""

# A server-side ee.FeatureCollection of power plants in Belgium.
fc_server = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')

# Use getInfo to transfer server-side feature collection to the client. The
# result is an object.
fc_client = fc_server.getInfo()
print('Client-side feature collection is a dictionary:', type(fc_client))
print('Feature collection dictionary keys:', fc_client.keys())
print('Array of features:', fc_client['features'])
print('Properties of first feature:', fc_client['features'][0]['properties'])