ee.String.evaluate
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Asynchronicznie pobiera wartość tego obiektu z serwera i przekazuje ją do podanej funkcji wywołania zwrotnego.
Wykorzystanie | Zwroty |
---|
String.evaluate(callback) | |
Argument | Typ | Szczegóły |
---|
to: computedobject | ComputedObject | Instancja ComputedObject. |
callback | Funkcja | Funkcja w formacie function(success, failure), wywoływana, gdy serwer zwraca odpowiedź. Jeśli żądanie się powiodło, argument success zawiera oceniony wynik. Jeśli żądanie się nie powiedzie, argument failure będzie zawierać komunikat o błędzie. |
Przykłady
Edytor kodu (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
});
Konfiguracja Pythona
Informacje o interfejsie Python API i używaniu geemap
do interaktywnego programowania znajdziesz na stronie
Środowisko 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.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eevaluate()\u003c/code\u003e retrieves the value of a server-side ComputedObject (like an \u003ccode\u003eee.String\u003c/code\u003e) and passes it to a client-side callback function.\u003c/p\u003e\n"],["\u003cp\u003eThis function is primarily used for transferring data from the Earth Engine servers to the client for tasks like displaying information in UI elements.\u003c/p\u003e\n"],["\u003cp\u003eExcessive use of \u003ccode\u003eevaluate()\u003c/code\u003e can impact performance and should be used judiciously, opting for server-side operations whenever possible.\u003c/p\u003e\n"],["\u003cp\u003eThe Python client library uses \u003ccode\u003egetInfo()\u003c/code\u003e for asynchronous evaluation instead of \u003ccode\u003eevaluate()\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# ee.String.evaluate\n\n\u003cbr /\u003e\n\nAsynchronously retrieves the value of this object from the server and passes it to the provided callback function.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------|---------|\n| String.evaluate`(callback)` | |\n\n| Argument | Type | Details |\n|------------------------|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `computedobject` | ComputedObject | The ComputedObject instance. |\n| `callback` | Function | A function of the form function(success, failure), called when the server returns an answer. If the request succeeded, the success argument contains the evaluated result. If the request failed, the failure argument will contains an error message. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n/**\n * WARNING: this function transfers data from Earth Engine servers to the\n * client. Doing so can negatively affect request processing and client\n * performance. Server-side options should be used whenever possible.\n * Learn more about the distinction between server and client:\n * https://developers.google.com/earth-engine/guides/client_server\n */\n\n// A server-side ee.String object fetched from a feature property.\nvar stringServer = ee.Feature(null, {lc: 'grassland'}).getString('lc');\n\n// Use evaluate to transfer server-side string to client for use in ui.Label.\nstringServer.evaluate(function(stringClient) {\n print('Client-side primitive data type', typeof stringClient); // string\n print('Client-side string', stringClient); // grassland\n print('Client-side string used in ui.Label',\n ui.Label('Land cover: ' + stringClient)); // Land cover: grassland\n});\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# The Earth Engine Python client library does not have an evaluate method for\n# asynchronous evaluation of ee.String objects.\n# Use ee.String.getInfo() instead.\n```"]]