اجرای معوق
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Doc Client vs. Server توضیح می دهد که چگونه اشیاء ارجاع شده در اسکریپت شما می توانند سمت کلاینت یا سمت سرور باشند. اسکریپت کامل نه تنها شامل اشیایی است که میخواهید استفاده کنید، بلکه مجموعهای از دستورالعملها را نیز شامل میشود که به Earth Engine میگوید با آنها چه کار کند. این سند توضیح میدهد که چگونه این دستورالعملها برای پردازش به Google ارسال میشوند و چگونه نتایج برای نمایش به مشتری ارسال میشوند.
هنگامی که یک اسکریپت را در Earth Engine می نویسید (یا جاوا اسکریپت یا پایتون)، آن کد مستقیماً روی سرورهای Earth Engine در Google اجرا نمی شود. در عوض، کتابخانه مشتری اسکریپت را در مجموعه ای از اشیاء JSON رمزگذاری می کند، اشیاء را به Google ارسال می کند و منتظر پاسخ می ماند. هر شی نشان دهنده مجموعه ای از عملیات مورد نیاز برای به دست آوردن یک خروجی خاص است، برای مثال یک تصویر برای نمایش در مشتری. کد زیر را در نظر بگیرید:
ویرایشگر کد (جاوا اسکریپت)
var image = ee.Image('CGIAR/SRTM90_V4');
var operation = image.add(10);
print(operation.toString());
print(operation);
راه اندازی پایتون
برای اطلاعات در مورد API پایتون و استفاده از geemap
برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.
import ee
import geemap.core as geemap
کولب (پایتون)
image = ee.Image('CGIAR/SRTM90_V4')
operation = image.add(10)
print(operation)
print(operation.getInfo())
اولین دستور چاپی ساختار JSON را که کتابخانه مشتری برای توصیف آن تصویر به سرور در Google استفاده می کند، خروجی می دهد:
ee.Image({
"type": "Invocation",
"arguments": {
"image1": {
"type": "Invocation",
"arguments": {
"id": "CGIAR/SRTM90_V4"
},
"functionName": "Image.load"
},
"image2": {
"type": "Invocation",
"arguments": {
"value": 10
},
"functionName": "Image.constant"
}
},
"functionName": "Image.add"
})
دستور چاپ دوم درخواست را به Google ارسال می کند و پاسخ POST را از سرورهای Google ارائه می دهد. برای مشاهده پاسخ در تمام شکوه JSON، روی پیوند JSON
در سمت راست کنسول، در کنار شی چاپ شده کلیک کنید:
{
"type": "Image",
"bands": [
{
"id": "elevation",
"data_type": {
"type": "PixelType",
"precision": "int",
"min": -32758,
"max": 32777
},
"crs": "EPSG:4326",
"crs_transform": [
0.0008333333535119891,
0,
-180,
0,
-0.0008333333535119891,
60
]
}
]
}
تا زمانی که درخواستی برای آن وجود نداشته باشد، هیچ چیزی برای پردازش به Google ارسال نمی شود. در این مثال، چاپ نتیجه یک فراخوانی getInfo()
روی یک شی سرور، یک درخواست را راهاندازی میکند. تا زمانی که آن نتیجه صریحاً درخواست نشود، هیچ پردازشی روی سرور انجام نمیشود. توجه داشته باشید که print()
در ویرایشگر کد جاوا اسکریپت یک تابع ویژه سمت کلاینت است که فراخوانی getInfo()
ناهمزمان را میپیچد. برای پایتون ما آن را مستقیماً صدا می زنیم.
نمونه دیگری از درخواست چیزی، نمایش آن در کد ویرایشگر یا عنصر نقشه geemap است. هنگامی که این درخواست به Google ارسال می شود، فقط کاشی های لازم برای نمایش نتیجه در ویرایشگر کد یا عنصر نقشه geemap برگردانده می شوند. به طور خاص، موقعیت نقشه و سطح زوم تعیین می کند که کدام داده ها پردازش شده و به تصاویر قابل نمایش روی نقشه تبدیل می شوند. اگر حرکت یا زوم میکنید، توجه داشته باشید که سایر کاشیها با تنبلی محاسبه میشوند. این سیستم بر اساس تقاضا امکان موازی سازی و پردازش کارآمد را فراهم می کند، اما همچنین به این معنی است که تصویر نمایش داده شده بر روی نقشه از ورودی های مختلف بسته به سطح بزرگنمایی و محل محدوده نقشه تولید می شود. درباره نحوه تعیین ورودیهای یک محاسبات از درخواست در Scale doc بیشتر بیاموزید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eEarth Engine code execution involves encoding scripts into JSON objects by the client library and sending them to Google servers for processing, with results returned to the client for display.\u003c/p\u003e\n"],["\u003cp\u003eProcessing on Google servers is triggered only when there's an explicit request, such as printing an object's information or displaying it on a map.\u003c/p\u003e\n"],["\u003cp\u003eEarth Engine employs a lazy processing system where only the necessary data for the current view is computed, improving efficiency and allowing for parallelization.\u003c/p\u003e\n"],["\u003cp\u003eThe displayed image on the map depends on the zoom level and map bounds, resulting in different inputs being used for computation at various scales.\u003c/p\u003e\n"],["\u003cp\u003eFurther details on how inputs are determined for computations based on requests can be found in the Scale documentation.\u003c/p\u003e\n"]]],[],null,["# Deferred Execution\n\nThe [Client vs. Server](/earth-engine/guides/client_server) doc describes how objects referenced\nin your script can be either client-side or server-side. The complete script contains\nnot only the objects you want to use, but also a set of instructions that tell Earth Engine\nwhat to do with them. This doc describes how those instructions are sent to Google for\nprocessing and how the results are sent back to the client for display.\n\nWhen you write a script in Earth Engine (either JavaScript or Python), that code does\nNOT run directly on Earth Engine servers at Google. Instead, the\n[client library](https://github.com/google/earthengine-api) encodes the\nscript into a set of [JSON](http://www.json.org/) objects, sends the objects\nto Google and waits for a response. Each object represents a set of operations\nrequired to get a particular output, an image to display in the client, for example.\nConsider the following code:\n\n### Code Editor (JavaScript)\n\n```javascript\nvar image = ee.Image('CGIAR/SRTM90_V4');\nvar operation = image.add(10);\nprint(operation.toString());\nprint(operation);\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\nimage = ee.Image('CGIAR/SRTM90_V4')\noperation = image.add(10)\nprint(operation)\nprint(operation.getInfo())\n```\n\nThe first print statement will output the JSON structure that the client library\nuses to describe that image to the server at Google: \n\n```gdscript\nee.Image({\n \"type\": \"Invocation\",\n \"arguments\": {\n \"image1\": {\n \"type\": \"Invocation\",\n \"arguments\": {\n \"id\": \"CGIAR/SRTM90_V4\"\n },\n \"functionName\": \"Image.load\"\n },\n \"image2\": {\n \"type\": \"Invocation\",\n \"arguments\": {\n \"value\": 10\n },\n \"functionName\": \"Image.constant\"\n }\n },\n \"functionName\": \"Image.add\"\n})\n \n```\n\nThe second print statement will send the request to Google and output the\n[POST](https://en.wikipedia.org/wiki/POST_(HTTP)) response from Google\nservers. To see the response in all its JSON glory, click the `JSON` link\non the right side of the console, next to the printed object: \n\n```carbon\n{\n \"type\": \"Image\",\n \"bands\": [\n {\n \"id\": \"elevation\",\n \"data_type\": {\n \"type\": \"PixelType\",\n \"precision\": \"int\",\n \"min\": -32758,\n \"max\": 32777\n },\n \"crs\": \"EPSG:4326\",\n \"crs_transform\": [\n 0.0008333333535119891,\n 0,\n -180,\n 0,\n -0.0008333333535119891,\n 60\n ]\n }\n ]\n}\n \n```\n\nNothing is sent to Google for processing until there is a request for it. In this\nexample, printing the result of a `getInfo()` call on a server object triggers a\nrequest. No processing is done on the server until that result is explicitly\nrequested. Note that `print()` in the JavaScript Code Editor is a special\nclient-side function that wraps an asynchronous `getInfo()` call; for Python we\ncall it directly.\n\nAnother example of requesting something is displaying it on the Code Editor or geemap map\nelement. When this request is sent to Google, only the tiles\nnecessary to display the result in the Code Editor or geemap map element are returned.\nSpecifically, the position of the map and the zoom level determine which data get processed\nand turned into images that can be displayed on the map. If you pan or zoom, note that\nother tiles are computed lazily. This on-demand system allows for parallelization and\nefficient processing, but also means that the image displayed on the map is produced from\ndifferent inputs depending on the zoom level and location of the map bounds. Learn more about\nhow inputs to a computation are determined from the request in the\n[Scale](/earth-engine/guides/scale) doc."]]