ee.Dictionary.getInfo

從伺服器擷取這個物件的值。

如果未提供任何回呼函式,系統會同步發出要求。如果提供回呼,系統會以非同步方式發出要求。

建議使用非同步模式,因為同步模式會在等待伺服器時停止所有其他程式碼 (例如 EE 程式碼編輯器使用者介面)。如要發出非同步要求,建議使用 evaluate(),而非 getInfo()。

傳回這個物件的計算值。

用量傳回
Dictionary.getInfo(callback)物件
引數類型詳細資料
這個:computedobjectComputedObjectComputedObject 例項。
callback函式 (選用)選用回呼。如未提供,系統會同步發出呼叫。

範例

程式碼編輯器 (JavaScript)

// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
  B1: 182,
  B2: 219,
  B3: 443
});

// Request the server-side ee.Dictionary as a client-side object.
print('Client-side object', dict.getInfo());
print('Using the client-side object', Object.keys(dict.getInfo()).length);

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
    'B1': 182,
    'B2': 219,
    'B3': 443
})

# Request the server-side ee.Dictionary as a client-side object.
print('Client-side object:', dic.getInfo())
print('Using the client-side object (e.g. fetch number of keys):',
      len(dic.getInfo().keys()))