ee.String.evaluate

从服务器异步检索此对象的值,并将其传递给提供的回调函数。

用法返回
String.evaluate(callback)
参数类型详细信息
this:computedobjectComputedObjectComputedObject 实例。
callback函数一个采用 function(success, failure) 形式的函数,在服务器返回答案时调用。如果请求成功,则 success 实参会包含评估结果。如果请求失败,失败参数将包含出错提示。

示例

代码编辑器 (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.String object fetched from a feature property.
var stringServer = ee.Feature(null, {lc: 'grassland'}).getString('lc');

// Use evaluate to transfer server-side string to client for use in ui.Label.
stringServer.evaluate(function(stringClient) {
  print('Client-side primitive data type', typeof stringClient);  // string
  print('Client-side string', stringClient);  // grassland
  print('Client-side string used in ui.Label',
        ui.Label('Land cover: ' + stringClient));  // Land cover: grassland
});

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请访问 Python 环境页面。

import ee
import geemap.core as geemap

Colab (Python)

# The Earth Engine Python client library does not have an evaluate method for
# asynchronous evaluation of ee.String objects.
# Use ee.String.getInfo() instead.