ee.String.getInfo

Recupera il valore di questo oggetto dal server.

Se non viene fornita alcuna funzione di callback, la richiesta viene eseguita in modo sincrono. Se viene fornita una funzione di callback, la richiesta viene effettuata in modo asincrono.

La modalità asincrona è preferita perché la modalità sincrona interrompe tutto il resto del codice (ad esempio, la UI dell'editor di codice EE) durante l'attesa del server. Per effettuare una richiesta asincrona, è preferibile utilizzare evaluate() anziché getInfo().

Restituisce il valore calcolato di questo oggetto.

UtilizzoResi
String.getInfo(callback)Oggetto
ArgomentoTipoDettagli
questo: computedobjectComputedObjectL'istanza ComputedObject.
callbackFunzione, facoltativaUn callback facoltativo. Se non viene fornito, la chiamata viene effettuata in modo sincrono.

Esempi

Editor di codice (JavaScript)

// After getInfo(), the instance is a local JavaScript string.
// Regular JavaScript string manipulations are then available.
//
// Note: getInfo() fetches results from Earth Engine immediately, and may freeze
// the browser or lead to poor performance.  Use evaluate() to avoid this.

print(ee.String('abc').getInfo().charAt(1));  // b
print(ee.String('abc').getInfo()[2]);         // c

// Using + with ee.String has unexpected results
print(ee.String('abc') + 'def');  // ee.String("abc")def

// Fetch string using getInfo
print(ee.String('abc').getInfo() + 'def');  // abcdef

// Improved solution: cat is available on ee.String
print(ee.String('abc').cat('def'));  // abcdef

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

import ee
import geemap.core as geemap

Colab (Python)

# After getInfo(), the instance is a local Python string.
# Regular Python string manipulations are then available.

# Note: getInfo() fetches results from Earth Engine synchronously;
# later expressions will not be evaluated until it completes.

print(ee.String('abc').getInfo()[-2])  # b
print(ee.String('abc').getInfo()[2])  # c

# Fetch string using getInfo
print(ee.String('abc').getInfo() + 'def')  # abcdef