ee.Number.evaluate
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เรียกค่าของออบเจ็กต์นี้จากเซิร์ฟเวอร์แบบไม่พร้อมกันและส่งไปยังฟังก์ชันเรียกกลับที่ระบุ
การใช้งาน | การคืนสินค้า |
---|
Number.evaluate(callback) | |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ computedobject | ComputedObject | อินสแตนซ์ ComputedObject |
callback | ฟังก์ชัน | ฟังก์ชันของรูปแบบ function(success, failure) ซึ่งจะเรียกใช้เมื่อเซิร์ฟเวอร์ส่งคำตอบกลับมา หากคำขอสำเร็จ อาร์กิวเมนต์ความสำเร็จจะมีผลลัพธ์ที่ประเมินแล้ว หากคำขอไม่สำเร็จ อาร์กิวเมนต์ failure จะมีข้อความแสดงข้อผิดพลาด |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (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.
numberServer.evaluate(function(numberClient) {
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
ดูข้อมูลเกี่ยวกับ 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.Number objects.
# Use ee.Number.getInfo() instead.
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eevaluate()\u003c/code\u003e is a method of the \u003ccode\u003eComputedObject\u003c/code\u003e class and allows retrieving the value of the object from the Earth Engine server asynchronously.\u003c/p\u003e\n"],["\u003cp\u003eIt takes a callback function that handles the evaluated result or any potential errors encountered during evaluation.\u003c/p\u003e\n"],["\u003cp\u003eThe provided example demonstrates how to use \u003ccode\u003eevaluate()\u003c/code\u003e to transfer a server-side \u003ccode\u003eee.Number\u003c/code\u003e to the client in JavaScript.\u003c/p\u003e\n"],["\u003cp\u003eWhile JavaScript utilizes \u003ccode\u003eevaluate()\u003c/code\u003e, the Python client library recommends using \u003ccode\u003egetInfo()\u003c/code\u003e for similar asynchronous evaluation of \u003ccode\u003eee.Number\u003c/code\u003e objects.\u003c/p\u003e\n"]]],["The `evaluate` method asynchronously retrieves a `ComputedObject`'s value from the server and provides it to a callback function. The callback receives a success argument with the result or a failure argument with an error message. It's called on a `Number` object. The examples demonstrated transfering a server-side number to the client, using the retrieved value. Python does not have this method and recommends `getInfo()` instead.\n"],null,["# ee.Number.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| Number.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.Number object.\nvar numberServer = ee.Number(10.3);\n\n// Use evaluate to transfer server-side number to the client.\nnumberServer.evaluate(function(numberClient) {\n print('Client-side primitive data type', typeof numberClient); // number\n print('Client-side number', numberClient); // 10.3\n print('Client-side number used in expression', numberClient + 10); // 20.3\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.Number objects.\n# Use ee.Number.getInfo() instead.\n```"]]