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 API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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