با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
لایه داده شدت تغییر وقوع آب معیاری از چگونگی تغییر آب های سطحی بین دو دوره را ارائه می دهد: 1984-1999 و 2000-2015. این لایه میانگین تغییرات در جفت های همولوگ ماه های گرفته شده از دو دوره را نشان می دهد. برای جزئیات بیشتر در مورد این لایه به راهنمای کاربران داده (v2) مراجعه کنید.
این بخش از آموزش به شرح زیر خواهد بود:
یک لایه نقشه سبک برای تجسم شدت تغییر وقوع آب اضافه کنید و
با استفاده از یک هیستوگرام، شدت تغییر را در یک منطقه مورد علاقه خاص خلاصه کنید.
تجسم
مشابه لایه وقوع آب، با افزودن یک تجسم اولیه از شدت تغییر وقوع به نقشه شروع می کنیم و سپس آن را بهبود می بخشیم. شدت تغییر وقوع به دو صورت هم به صورت مقادیر مطلق و هم به صورت نرمال شده ارائه می شود. ما در این آموزش از مقادیر مطلق استفاده خواهیم کرد. با انتخاب لایه شدت تغییر وقوع مطلق از تصویر GSW شروع کنید:
در بخش Constants کد، عبارتی اضافه کنید که یک متغیر جدید ایجاد می کند که نحوه استایل دهی لایه را مشخص می کند. این یک ظاهر طراحی شده مناطقی را نشان می دهد که در آن وقوع آب سطحی به رنگ قرمز/سبز کاهش/افزایش یافته است. مناطقی که وقوع آب های سطحی نسبتاً بدون تغییر است با رنگ سیاه نشان داده شده اند.
در این بخش، مقدار تغییر در یک منطقه خاص مورد علاقه را خلاصه می کنیم. برای تعیین منطقه مورد نظر، روی ابزار ترسیم چند ضلعی که یکی از ابزارهای هندسه است، کلیک کنید. این یک لایه جدید Geometry Imports ایجاد می کند که به طور پیش فرض "geometry" نام دارد. برای تغییر نام، روی نماد چرخ دنده واقع در سمت راست نام لایه کلیک کنید. (توجه داشته باشید که ممکن است لازم باشد مکان نما را روی نام لایه قرار دهید تا ظاهر شود.)
نام لایه را به roi (برای منطقه مورد علاقه یا ROI) تغییر دهید. سپس میتوانیم روی یک سری از نقاط روی نقشه کلیک کنیم تا یک منطقه چند ضلعی مورد نظر را تعریف کنیم.
شکل 7. تصویری از رودخانه Ucayali در نزدیکی Pucallpa، پرو، با منطقه مورد علاقه ایجاد شده با استفاده از ابزار ترسیم چند ضلعی.
اکنون که منطقه مورد علاقه ما در یک متغیر تعریف و ذخیره شده است، می توانیم از آن برای محاسبه هیستوگرام شدت تغییر برای ROI استفاده کنیم. کد زیر را به قسمت Calculations اسکریپت اضافه کنید.
عبارت اول یک هیستوگرام از مقادیر شدت تغییر رخداد را در ROI محاسبه می کند، نمونه برداری در مقیاس 30 متر. دومی شی حاصل را در تب Console ویرایشگر کد چاپ می کند. می توانید درخت شی را برای مشاهده مقادیر سطل های هیستوگرام گسترش دهید. داده های عددی وجود دارد، اما راه های بهتری برای تجسم نتایج وجود دارد.
شکل 8. نتایج زبانه کنسول، مقادیر هیستوگرام شدت تغییر آب سطحی را نشان می دهد.
برای بهبود این موضوع، می توانیم به جای آن یک نمودار هیستوگرام ایجاد کنیم. عبارتی را که شی هیستوگرام را تعریف می کند با عبارات زیر جایگزین کنید:
این عبارات یک شی نمودار هیستوگرام ایجاد می کند، که درخت شی هیستوگرام در تب کنسول را با نمودار جایگزین می کند. روش نمودار شامل چندین آرگومان است، از جمله scale که مقیاس فضایی را تعریف می کند، بر حسب متر، که در آن منطقه مورد نظر نمونه برداری می شود، و minBucketWidth که برای کنترل عرض سطل های هیستوگرام استفاده می شود.
شکل 9. نتایج زبانه کنسول، نمودار هیستوگرام شدت تغییر آب سطحی را نشان می دهد.
می توانید با قرار دادن مکان نما روی نوارهای هیستوگرام، مقادیر نمودار را به صورت تعاملی کشف کنید.
اسکریپت نهایی
کل اسکریپت این بخش در زیر فهرست شده است. توجه داشته باشید که این اسکریپت شامل عباراتی برای تعریف هندسه چند ضلعی ( roi ) است که با هندسه ای که با استفاده از ابزارهای هندسه ویرایشگر کد ایجاد کرده اید قابل مقایسه است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Water Occurrence Change Intensity data layer shows surface water changes between 1984-1999 and 2000-2015.\u003c/p\u003e\n"],["\u003cp\u003eThis tutorial demonstrates visualizing water occurrence change intensity with a styled map layer, using red for decreased and green for increased surface water.\u003c/p\u003e\n"],["\u003cp\u003eIt also covers summarizing the change intensity within a user-defined region of interest using a histogram chart generated in the Code Editor.\u003c/p\u003e\n"],["\u003cp\u003eUsers can interactively explore the chart to understand the distribution of surface water change intensity values within their chosen region.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial utilizes the Global Surface Water dataset and provides JavaScript code examples for implementation in Google Earth Engine.\u003c/p\u003e\n"]]],["The core content details analyzing changes in surface water between 1984-1999 and 2000-2015. Key actions include visualizing \"water occurrence change intensity\" using absolute values and a defined color palette (red for decrease, green for increase, black for no change). Users can define a region-of-interest (ROI) and calculate a histogram to summarize the change intensity within that area. The process involves generating and customizing a histogram chart, which is then printed to the console for interactive exploration.\n"],null,["# Water Occurrence Change Intensity\n\nThe Water Occurrence Change Intensity data layer provides a measure of how surface water has\nchanged between two epochs: 1984-1999 and 2000-2015. The layer averages the change across\nhomologous pairs of months taken from the two epochs. See the\n[Data Users Guide (v2)](https://storage.googleapis.com/global-surface-water/downloads_ancillary/DataUsersGuidev2.pdf) for additional details on this layer.\n\nThis section of the tutorial will:\n\n1. add a styled map layer for visualizing water occurrence change intensity, and\n2. summarize the change intensity in a specified region-of-interest using a histogram.\n\nVisualization\n-------------\n\nSimilar to the water occurrence layer, we will start by adding a basic visualization of\noccurrence change intensity to the map and then improve upon it. Occurrence change intensity\nis provided in two ways, both as absolute and normalized values. We will use the absolute\nvalues in this tutorial.\nStart by selecting the absolute occurrence change intensity layer from the GSW image:\n\n### Code Editor (JavaScript)\n\n```javascript\nvar change = gsw.select(\"change_abs\");\n```\n\nIn the Constants section of the code, add a statement that creates a new variable that\ndefines how the layer will be styled. This styling shows areas where the surface water\noccurrence has decreased/increased in red/green. Areas where surface water occurrence\nis relatively unchanged are shown in black.\n\n### Code Editor (JavaScript)\n\n```javascript\nvar VIS_CHANGE = {\n min:-50,\n max:50,\n palette: ['red', 'black', 'limegreen']\n};\n```\n\nAt the end of the Map Layers section of code, add a statement that adds a new layer to\nthe map.\n\n### Code Editor (JavaScript)\n\n```javascript\nMap.setCenter(-74.4557, -8.4289, 11); // Ucayali River, Peru\nMap.addLayer({\n eeObject: change,\n visParams: VIS_CHANGE,\n name: 'occurrence change intensity'\n});\n```\nFigure 6. Screenshot of a surface water change intensity for the Ucayali River near Pucallpa, a city in the Amazonian rainforest of eastern Peru. Red/green indicates a decrease/increase in surface water occurrence between the epochs.\n\nSummarizing Change within a Region of Interest\n----------------------------------------------\n\nIn this section, we will summarize the amount of change within a specified region of\ninterest. To specify a region of interest, click on the polygon drawing tool, which is one of\nthe\n[Geometry tools](/earth-engine/guides/playground#geometry-tools).\nThis will create a new Geometry Imports layer, which is named \"geometry\"\nby default. To change the name, click on the gear icon located to the right of the to the\nlayer name. (Note that you may need to place your cursor on the layer name to make it appear.)\n\nChange the layer name to `roi` (for region-of-interest or ROI). We then can click on a\nseries of points on the map to define a polygon region of interest.\nFigure 7. Screenshot of the Ucayali River near Pucallpa, Peru, with a region-of-interest created by using the polygon drawing tool.\n\nNow that our region-of-interest is defined and stored in a variable, we can use it to\ncalculate a histogram of the change intensity for the ROI. Add the following code to the\nCalculations section of the script.\n\n### Code Editor (JavaScript)\n\n```javascript\n// Calculate a change intensity for the region of interest.\nvar histogram = change.reduceRegion({\n reducer: ee.Reducer.histogram(),\n geometry: roi,\n scale: 30,\n bestEffort: true,\n});\nprint(histogram);\n```\n\nThe first statement calculates a histogram of occurrence change intensity values within the\nROI, sampling at a 30m scale. The second prints the resulting object to the Code Editor\nConsole Tab. You can expand out the object tree to view the values of the histogram buckets.\nThe numeric data is there, but there are better ways to visualize the results.\nFigure 8. Console tab results, showing histogram values of surface water change intensity.\n\nTo improve upon this, we can generate a histogram chart instead. Replace the statement that\ndefines the histogram object with the following statements:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Generate a histogram object and print it to the console tab.\nvar histogram = ui.Chart.image.histogram({\n image: change,\n region: roi,\n scale: 30,\n minBucketWidth: 10\n});\nhistogram.setOptions({\n title: 'Histogram of surface water change intensity.'\n});\n```\n\nThese statements create a histogram chart object, which replaces the histogram object tree\nin the Console Tab with a chart. The chart method contains several arguments, including\n`scale` which defines the spatial scale, in meters, at which the region of interest'\nis sampled, and\n`minBucketWidth` which is used to control the width of the histogram\nbuckets.\nFigure 9. Console tab results, showing a histogram chart of surface water change intensity.\n\nYou can explore the chart values interactively by placing your cursor over the histogram\nbars.\n\nFinal Script\n------------\n\nThe entire script for this section is listed below. Note that the script includes statements\nfor defining a polygon geometry (`roi`), which is comparable to the geometry that\nyou created using the Code Editor's geometry tools.\n\n### Code Editor (JavaScript)\n\n```javascript\n//////////////////////////////////////////////////////////////\n// Asset List\n//////////////////////////////////////////////////////////////\n\nvar gsw = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');\nvar occurrence = gsw.select('occurrence');\nvar change = gsw.select(\"change_abs\");\nvar roi = /* color: 0B4A8B */ee.Geometry.Polygon(\n [[[-74.17213, -8.65569],\n [-74.17419, -8.39222],\n [-74.38362, -8.36980],\n [-74.43031, -8.61293]]]);\n\n//////////////////////////////////////////////////////////////\n// Constants\n//////////////////////////////////////////////////////////////\n\nvar VIS_OCCURRENCE = {\n min:0,\n max:100,\n palette: ['red', 'blue']\n};\nvar VIS_CHANGE = {\n min:-50,\n max:50,\n palette: ['red', 'black', 'limegreen']\n};\nvar VIS_WATER_MASK = {\n palette: ['white', 'black']\n};\n\n//////////////////////////////////////////////////////////////\n// Calculations\n//////////////////////////////////////////////////////////////\n\n// Create a water mask layer, and set the image mask so that non-water areas are transparent.\nvar water_mask = occurrence.gt(90).mask(1);\n\n// Generate a histogram object and print it to the console tab.\nvar histogram = ui.Chart.image.histogram({\n image: change,\n region: roi,\n scale: 30,\n minBucketWidth: 10\n});\nhistogram.setOptions({\n title: 'Histogram of surface water change intensity.'\n});\nprint(histogram);\n\n//////////////////////////////////////////////////////////////\n// Initialize Map Location\n//////////////////////////////////////////////////////////////\n\n// Uncomment one of the following statements to center the map on\n// a particular location.\n// Map.setCenter(-90.162, 29.8597, 10); // New Orleans, USA\n// Map.setCenter(-114.9774, 31.9254, 10); // Mouth of the Colorado River, Mexico\n// Map.setCenter(-111.1871, 37.0963, 11); // Lake Powell, USA\n// Map.setCenter(149.412, -35.0789, 11); // Lake George, Australia\n// Map.setCenter(105.26, 11.2134, 9); // Mekong River Basin, SouthEast Asia\n// Map.setCenter(90.6743, 22.7382, 10); // Meghna River, Bangladesh\n// Map.setCenter(81.2714, 16.5079, 11); // Godavari River Basin Irrigation Project, India\n// Map.setCenter(14.7035, 52.0985, 12); // River Oder, Germany & Poland\n// Map.setCenter(-59.1696, -33.8111, 9); // Buenos Aires, Argentina\\\nMap.setCenter(-74.4557, -8.4289, 11); // Ucayali River, Peru\n\n//////////////////////////////////////////////////////////////\n// Map Layers\n//////////////////////////////////////////////////////////////\n\nMap.addLayer({\n eeObject: water_mask,\n visParams: VIS_WATER_MASK,\n name: '90% occurrence water mask',\n shown: false\n});\nMap.addLayer({\n eeObject: occurrence.updateMask(occurrence.divide(100)),\n name: \"Water Occurrence (1984-2015)\",\n visParams: VIS_OCCURRENCE,\n shown: false\n});\nMap.addLayer({\n eeObject: change,\n visParams: VIS_CHANGE,\n name: 'occurrence change intensity'\n});\n```\n\nIn the [next section](/earth-engine/tutorials/tutorial_global_surface_water_04), you will further\nexplore how water changed over time, by working with the water class **transition** layer."]]