ee.Number.getInfo

Retrieves the value of this object from the server.

If no callback function is provided, the request is made synchronously. If a callback is provided, the request is made asynchronously.

The asynchronous mode is preferred because the synchronous mode stops all other code (for example, the EE Code Editor UI) while waiting for the server. To make an asynchronous request, evaluate() is preferred over getInfo().

Returns the computed value of this object.

UsageReturns
Number.getInfo(callback)Object
ArgumentTypeDetails
this: computedobjectComputedObjectThe ComputedObject instance.
callbackFunction, optionalAn optional callback. If not supplied, the call is made synchronously.

Examples

Code Editor (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.Number object.
var numberServer = ee.Number(10.3);

// Use evaluate to transfer server-side number to the client.
var numberClient = numberServer.getInfo();
print('Client-side primitive data type', typeof numberClient);  // number
print('Client-side number', numberClient);  // 10.3
print('Client-side number used in expression', numberClient + 10);  // 20.3

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

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.Number object.
number_server = ee.Number(10.3)

number_client = number_server.getInfo()
print('Client-side primitive data type:', type(number_client))  # float
print('Client-side number:', number_client)  # 10.3
print('Client-side number used in expression:', number_client + 10)  # 20.3