Anuncio: Todos los proyectos no comerciales registrados para usar Earth Engine antes del 15 de abril de 2025 deben verificar su elegibilidad no comercial para mantener el acceso a Earth Engine.
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
La capa de datos de Intensidad del cambio en la ocurrencia de agua proporciona una medida de cómo cambió el agua superficial entre dos épocas: 1984-1999 y 2000-2015. La capa calcula el promedio del cambio en pares homólogos de meses tomados de las dos épocas. Consulta la
Guía de usuarios de datos (v2)
para obtener más detalles sobre esta capa.
En esta sección del instructivo, se hará lo siguiente:
Agregar una capa de mapa con diseño para visualizar la intensidad del cambio en la presencia de agua
Resumir la intensidad del cambio en una región de interés especificada con un histograma
Visualización
Al igual que con la capa de ocurrencia de agua, comenzaremos por agregar una visualización básica de la intensidad del cambio de ocurrencia al mapa y, luego, la mejoraremos. La intensidad del cambio de ocurrencia se proporciona de dos maneras, tanto como valores absolutos como normalizados. En este instructivo, usaremos los valores absolutos.
Para comenzar, selecciona la capa de intensidad del cambio de ocurrencia absoluto en la imagen de GSW:
En la sección Constants del código, agrega una instrucción que cree una variable nueva que defina cómo se aplicará el diseño de la capa. Este diseño muestra las áreas en las que la presencia de agua superficial disminuyó o aumentó en rojo o verde, respectivamente. Las áreas en las que la presencia de agua superficial no cambió significativamente se muestran en negro.
Resumen del cambio dentro de una región de interés
En esta sección, resumiremos la cantidad de cambio dentro de una región de interés especificada. Para especificar una región de interés, haz clic en la herramienta de dibujo de polígonos, que es una de las
Herramientas de geometría.
Esto creará una nueva capa Geometry Imports, que se llamará "geometry" de forma predeterminada. Para cambiar el nombre, haz clic en el ícono de ajustes ubicado a la derecha del nombre de la capa. (Ten en cuenta que es posible que debas colocar el cursor sobre el nombre de la capa para que aparezca).
Cambia el nombre de la capa a roi (para la región de interés o ROI). Luego, podemos hacer clic en una
serie de puntos en el mapa para definir una región de interés poligonal.
Figura 7. Captura de pantalla del río Ucayali cerca de Pucallpa, Perú, con una región de interés creada con la herramienta de dibujo de polígonos.
Ahora que nuestra región de interés está definida y almacenada en una variable, podemos usarla para calcular un histograma de la intensidad del cambio para la ROI. Agrega el siguiente código a la sección Calculations de la secuencia de comandos.
La primera instrucción calcula un histograma de los valores de intensidad del cambio de ocurrencia dentro del ROI, con un muestreo a una escala de 30 m. El segundo imprime el objeto resultante en la pestaña de la consola del editor de código. Puedes expandir el árbol de objetos para ver los valores de los buckets del histograma.
Los datos numéricos están ahí, pero hay mejores maneras de visualizar los resultados.
Figura 8. Resultados de la pestaña de la consola, que muestran los valores del histograma de la intensidad del cambio en el agua superficial.
Para mejorar esto, podemos generar un gráfico de histograma. Reemplaza la instrucción que define el objeto de histograma por las siguientes instrucciones:
Estas instrucciones crean un objeto de gráfico de histograma, que reemplaza el árbol de objetos de histograma en la pestaña Console por un gráfico. El método del gráfico contiene varios argumentos, incluidos scale, que define la escala espacial, en metros, en la que se muestrea la región de interés, y minBucketWidth, que se usa para controlar el ancho de los buckets del histograma.
Figura 9. Resultados de la pestaña de la consola, que muestran un gráfico de histograma de la intensidad del cambio del agua superficial.
Puedes explorar los valores del gráfico de forma interactiva colocando el cursor sobre las barras del histograma.
Guion final
A continuación, se incluye el guion completo de esta sección. Ten en cuenta que la secuencia de comandos incluye instrucciones para definir una geometría de polígono (roi), que es comparable a la geometría que creaste con las herramientas de geometría del editor de código.
[null,null,["Última actualización: 2025-07-27 (UTC)"],[[["\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."]]