با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Earth Engine یک ابزار تحلیلی قدرتمند است، اما ممکن است لازم باشد نتایج تجزیه و تحلیل خود را صادر کنید تا نمودارها، تصاویر، نقشهها و غیره را در گزارشها یا نشریات جاسازی کنید. در این قسمت با نحوه ایجاد نمودارها و تصاویر قابل صادرات و مشاهده در نرم افزارهای دیگر آشنا می شوید. به یاد بیاورید که در بخش قبل ، از کدی مانند زیر برای اضافه کردن یک باند NDVI به هر تصویر در یک مجموعه استفاده کردید، جایی که متغیر l8 به مجموعه بازتاب Landsat 8 TOA اشاره می کند:
فرض کنید آنچه شما می خواهید در واقع نمودار NDVI در طول زمان در یک مکان مشخص است. برای ایجاد چنین نموداری، اولین قدم انتخاب مکان مورد علاقه است. با گرفتن ابزار ترسیم نقطه، یک نقطه ایجاد کنید ( ) و یک هندسه تک نقطه ای در منطقه مورد علاقه خود ایجاد کنید. (اگر قبلاً واردات دارید، روی Geometry Imports بروید و ابتدا + لایه جدید را کلیک کنید). نقطه را در منطقه ای از کشاورزی، جنگل های برگریز، علفزار سالانه یا برخی از پوشش های زمین دیگر با چرخه سالانه قرار دهید). واردات roi نام ببرید. (برای اطلاعات در مورد ایجاد هندسه به صورت برنامه ای به این صفحه مراجعه کنید).
حالا بیایید از نقطه roi برای ایجاد نموداری از NDVI در طول زمان در پیکسل زیر آن نقطه استفاده کنیم. راه ساخت نمودار در Earth Engine با بسته ui.Chart است. ( در مورد ساخت نمودار در Earth Engine بیشتر بیاموزید ). به طور خاص، برای ایجاد نمودار در طول زمان، می توانید از متد ui.Chart.image.series() استفاده کنید:
برای هندسه roi ، نقطهای را در یک منطقه کشاورزی انتخاب کردیم که نتیجه آن نموداری است که چیزی شبیه به شکل 10 است. توجه داشته باشید که پارامترهای سازنده نمودار شامل یک کاهنده و مقیاسی مانند reduceRegion() هستند. از آنجایی که نقطه ای که ما به عنوان یک منطقه ارائه می کنیم فقط می تواند یک پیکسل را قطع کند، استفاده از کاهنده «اول» کافی است. اگر منطقه بزرگتری دارید، باید از «میانگین» یا کاهشدهنده دیگری استفاده کنید که نحوه جمعآوری پیکسلها را مشخص میکند. همچنین توجه داشته باشید که برای تجسم نمودار، تنها کاری که باید انجام دهید چاپ آن است.
شکل 10. نمودار Landsat NDVI در طول زمان در هندسه نقطه ای.
انحراف: پوشش ساده ابر برای Landsat
چیزی که ممکن است در مورد این نمودار متوجه شده باشید این است که سری زمانی مقادیر NDVI در آن نقطه کمی پر سر و صدا به نظر می رسد. این احتمالاً به دلیل ابرها است. برای بهبود این اثر، Earth Engine شامل یک الگوریتم پوشش ابری برای حسگرهای Landsat با باند حرارتی است: ee.Algorithms.Landsat.simpleCloudScore() . یک تصویر بازتابی Landsat TOA را به عنوان ورودی می گیرد و باندی به نام cloud را اضافه می کند که به ترتیب شاخص ابری بودن پیکسل از صفر تا 100، از حداقل تا ابری ترین است. با تغییر تابعی که روی مجموعه نگاشت کرده اید، می توانید از یک آستانه دلخواه (20) در فهرست ابری استفاده کنید تا نمودار را کمی تمیز کنید:
نتیجه پوشش ابری در شکل 11 نشان داده شده است. توجه داشته باشید که سری زمانی کمی صاف تر به نظر می رسد، اما ممکن است همچنان حاوی پیکسل های تحت تاثیر ابرها باشد. آستانه را در نمایه ابری تنظیم کنید و سری های زمانی نمودار شده را مشاهده کنید تا بدانید این آستانه چگونه می تواند بر نتایج شما تأثیر بگذارد.
شکل 11. نمودار NDVI ماسک شده با ابر در طول زمان در هندسه نقطه ای.
صادرات تصاویر
شما راهی برای صادرات نمودار داده های محاسبه شده توسط Earth Engine دیده اید، اما در مورد یک تصویر کامل چطور؟ به عنوان مثال، فرض کنید که یک کامپوزیت سبزترین پیکسل را همانطور که در بخش قبل توضیح داده شد ساخته اید:
تنها تفاوت این کد با آنچه قبلا انجام دادید این است که اکنون ما از مجموعه ابری ماسک شده استفاده می کنیم. شما می توانید یک زیر مجموعه (تعریف شده توسط یک منطقه) از آن را با استفاده از بسته Export صادر کنید. ( درباره صادر کردن داده های شطرنجی و برداری از Earth Engine بیشتر بیاموزید .) به عنوان مثال، برای صادر کردن تصویری که می تواند به راحتی در سایر اسناد جاسازی شود، بیایید یک تصویر تجسم ایجاد کنیم، همانطور که قبلاً انجام داده اید ، آن را به پوشه Google Drive خود صادر کنید:
وقتی این کد را اجرا می کنید، توجه داشته باشید که یک کار جدید در تب Tasks ایجاد می شود. برای راه اندازی گفتگوی پیکربندی صادرات، روی دکمه RUN در تب Tasks کلیک کنید. هنگامی که وظیفه را پیکربندی کردید، روی دکمه Run در گفتگو کلیک کنید تا صادرات شروع شود. اما قبل از انجام این کار، هشدار دهید:
دلیل اینکه هنگام صادرات بدون آرگومان region باید احتیاط کنید این است که اگر مقدار نسبتاً کوچکی را برای scale تعیین کنید و نقشه به ناحیه بزرگ کوچکنمایی شود، یک تصویر بالقوه بسیار بزرگ را به پوشه Drive خود صادر خواهید کرد. برای جزئیات بیشتر و لیستی از پارامترهای پیکربندی ممکن، به اسناد Export.image.toDrive() در برگه Docs مراجعه کنید.
این مقدمه برای Earth Engine API به پایان می رسد! شما اکنون بسیاری از رایج ترین عملکردهای Earth Engine را دیده اید و باید بتوانید با اطمینان به تحلیل های پیچیده تری بروید. حتماً اسناد را بخوانید و برای پاسخ به سوالات دیگر در انجمن جستجو کنید. کد نویسی مبارک!
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis tutorial explains how to export Earth Engine analysis results, like charts and images, for use in external reports or publications.\u003c/p\u003e\n"],["\u003cp\u003eIt demonstrates charting NDVI trends over time using \u003ccode\u003eui.Chart.image.series()\u003c/code\u003e, including applying cloud masking for data refinement.\u003c/p\u003e\n"],["\u003cp\u003eUsers learn to export images, such as a greenest-pixel composite, to Google Drive using the \u003ccode\u003eExport.image.toDrive()\u003c/code\u003e function, emphasizing the importance of specifying a region to control image size.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial highlights the need for cloud masking to improve data quality and provides a basic example using \u003ccode\u003eee.Algorithms.Landsat.simpleCloudScore()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt encourages further exploration of Earth Engine functionalities through documentation and the user forum.\u003c/p\u003e\n"]]],[],null,["# Exporting Charts and Images\n\nEarth Engine is a powerful analytical tool, but you may have need to export the results\nof your analysis in order to embed charts, images, maps, etc. into reports or\npublications. In this section, you will learn how to create charts and images\nthat can be exported and viewed in other software. Recall that in the\n[previous section](/earth-engine/tutorials/tutorial_api_06), you used code like the following to add an\nNDVI band to every image in a collection, where the `l8` variable references the\n[Landsat 8 TOA reflectance\ncollection](/earth-engine/datasets/catalog/LANDSAT_LC8_L1T_TOA):\n\n### Code Editor (JavaScript)\n\n```javascript\n// Import the Landsat 8 TOA image collection.\nvar l8 = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA');\n\n// Map a function over the Landsat 8 TOA collection to add an NDVI band.\nvar withNDVI = l8.map(function(image) {\n var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');\n return image.addBands(ndvi);\n});\n```\n\nCharting\n--------\n\nSuppose that what you want is actually a chart of NDVI over time at a given location. To\nmake such a chart, the first step is to choose a location of interest. Create a point\nby getting the point drawing tool ()\nand make a single point geometry in your area of interest. (If you already have imports,\nhover on **Geometry Imports** and click **+ new layer** first).\nLocate the point in an area of agriculture, deciduous forest, annual grassland or some\nother land cover with an annual cycle). Name the import `roi`. (See\n[this page](/earth-engine/guides/geometries) for information about creating geometries\nprogrammatically).\n\nNow let's use the `roi` point to make a chart of NDVI over time in the pixel\nunder that point. The way to make charts in Earth Engine is with the `ui.Chart`\npackage. ([Learn more about making charts in Earth Engine](/earth-engine/guides/charts)).\nSpecifically, to make a chart over time, you can use the\n`ui.Chart.image.series()` method:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a chart.\nvar chart = ui.Chart.image.series({\n imageCollection: withNDVI.select('NDVI'),\n region: roi,\n reducer: ee.Reducer.first(),\n scale: 30\n}).setOptions({title: 'NDVI over time'});\n\n// Display the chart in the console.\nprint(chart);\n```\n\nFor the `roi` geometry, we chose a point in an agricultural area, resulting\nin a chart that looks something like Figure 10. Note that the parameters to the chart\nconstructor include a reducer and scale like `reduceRegion()`. Since the\npoint we are providing as a region can only intersect one pixel, it suffices to use the\n'first' reducer. If you have a larger region, you should use a 'mean' or other reducer\nthat specifies how to aggregate pixels. Also note that to visualize a chart, all you\nhave to do is print it.\nFigure 10. Chart of Landsat NDVI over time at a point geometry. **Note:** The upper right corner of the chart contains a little pop-out icon (open_in_new). Click that icon to get a new tab with a version of the chart that can be downloaded in a variety of formats. See the `ui.Chart` section of the **Docs** tab for a complete list of the charting options in Earth Engine.\n\nDigression: Simple Cloud Masking for Landsat\n--------------------------------------------\n\nSomething you may have noticed about this chart is that the time series of NDVI values\nat the point looks a little noisy. This is likely due to clouds. To ameliorate this\neffect, Earth Engine includes a cloud-masking algorithm for Landsat sensors with a\nthermal band: `ee.Algorithms.Landsat.simpleCloudScore()`. It takes a Landsat TOA\nreflectance image as input and adds a band named `cloud` which is an index\nof cloudiness in the pixel from zero to 100, from least to most cloudy, respectively. By\nmodifying the function you mapped over the collection, you can use an arbitrary\nthreshold (20) on the cloud index to clean up the chart a bit:\n\n### Code Editor (JavaScript)\n\n```javascript\nvar cloudlessNDVI = l8.map(function(image) {\n // Get a cloud score in [0, 100].\n var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');\n\n // Create a mask of cloudy pixels from an arbitrary threshold.\n var mask = cloud.lte(20);\n\n // Compute NDVI.\n var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');\n\n // Return the masked image with an NDVI band.\n return image.addBands(ndvi).updateMask(mask);\n});\n\nprint(ui.Chart.image.series({\n imageCollection: cloudlessNDVI.select('NDVI'),\n region: roi,\n reducer: ee.Reducer.first(),\n scale: 30\n}).setOptions({title: 'Cloud-masked NDVI over time'}));\n```\n\nThe cloud-masked result is illustrated in Figure 11. Note that the time series looks a\nlittle smoother, but may still contain pixels affected by clouds. Adjust the threshold\non the cloud index and observe the charted time series to learn how this threshold can\naffect your results.\nFigure 11. Chart of cloud-masked NDVI over time at a point geometry.\n\nExporting Images\n----------------\n\nYou have seen a way to export a chart of data computed by Earth Engine, but what about a\nwhole image? Suppose, for example that you have built a greenest-pixel composite\n[as discussed in the previous\nsection](/earth-engine/tutorials/tutorial_api_06#make-a-greenest-pixel-composite):\n\n### Code Editor (JavaScript)\n\n```javascript\nvar greenest = cloudlessNDVI.qualityMosaic('NDVI');\n```\n\nThe only difference in this code from what you did previously is that now we're using\nthe cloud masked collection. You can export a subset (defined by a region) of this\nusing the `Export` package. ([Learn more about exporting\nraster and vector data from Earth Engine](/earth-engine/guides/exporting).) For example, to export an image that can be\neasily embedded in other docs, let's create a visualization image,\n[as you've done previously](/earth-engine/tutorials/tutorial_api_05#mosaicking), an Export it to your\nGoogle Drive folder:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a 3-band, 8-bit, color-IR composite to export.\nvar visualization = greenest.visualize({\n bands: ['B5', 'B4', 'B3'],\n max: 0.4\n});\n\n// Create a task that you can launch from the Tasks tab.\nExport.image.toDrive({\n image: visualization,\n description: 'Greenest_pixel_composite',\n scale: 30\n});\n```\n\nWhen you run this code, note that a new task is created in the **Tasks** tab.\nTo launch the export configuration dialog, click the **RUN** button in the\n**Tasks** tab. Once you've configured the task, click the **Run**\nbutton in the dialog to start the export. But before you do that, be warned:\n| **Caution:** If you don't specify a region, the Map bounds at the time the script is run will be used!\n\nThe reason you should exercise caution when exporting without a `region`\nargument is that if you set a relatively small value for `scale`, and the\nMap is zoomed out to large area, then you will export a potentially *very* large\nimage to your Drive folder. See the `Export.image.toDrive()` docs in the\n**Docs** tab for more details and a list of possible configuration parameters.\n\nThat concludes this introduction to the Earth Engine API! You have now seen much of\nthe most common Earth Engine functionality and should be able to confidently proceed to\nmore complex analyses. Be sure to [read the docs](/earth-engine/guides) and search the\n[forum](https://groups.google.com/forum/#!forum/google-earth-engine-developers)\nfor answers to other questions. Happy coding! \n[arrow_backPrevious page](/earth-engine/tutorials/tutorial_api_06)"]]