Annonce : Tous les projets non commerciaux enregistrés pour utiliser Earth Engine avant le 15 avril 2025 doivent vérifier leur éligibilité non commerciale pour conserver leur accès à Earth Engine.
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
La couche de données "Intensité de la variation de la présence d'eau" fournit une mesure de la façon dont les eaux de surface ont évolué entre deux époques : 1984-1999 et 2000-2015. La couche calcule la moyenne de la variation pour les paires de mois homologues issues des deux époques. Pour en savoir plus sur ce calque, consultez le
Guide de l'utilisateur des données (v2)
.
Cette section du tutoriel vous permettra de :
ajouter un calque de carte stylisé pour visualiser l'intensité de l'évolution de la présence d'eau ;
résumer l'intensité des changements dans une région d'intérêt spécifique à l'aide d'un histogramme.
Visualisation
Comme pour le calque d'occurrence de l'eau, nous allons commencer par ajouter une visualisation de base de l'intensité de la variation d'occurrence à la carte, puis l'améliorer. L'intensité de la variation d'occurrence est fournie de deux manières : sous forme de valeurs absolues et normalisées. Nous utiliserons les valeurs absolues dans ce tutoriel.
Commencez par sélectionner le calque d'intensité de variation absolue des occurrences dans l'image GSW :
Dans la section "Constants" (Constantes) du code, ajoutez une instruction qui crée une variable définissant le style de la couche. Ce style montre les zones où la présence d'eau de surface a diminué/augmenté en rouge/vert. Les zones où la présence d'eau de surface est relativement inchangée sont indiquées en noir.
Dans cette section, nous allons résumer l'ampleur du changement dans une région d'intérêt spécifique. Pour spécifier une région d'intérêt, cliquez sur l'outil de dessin de polygones, qui fait partie des
outils de géométrie.
Cela crée un calque "geometry" (géométrie) nommé "geometry" par défaut. Pour modifier le nom, cliquez sur l'icône en forme de roue dentée située à droite du nom du calque. (Notez que vous devrez peut-être placer le curseur sur le nom du calque pour qu'il apparaisse.)
Remplacez le nom du calque par roi (pour la région d'intérêt). Nous pouvons ensuite cliquer sur une série de points sur la carte pour définir une région d'intérêt polygonale.
Figure 7. Capture d'écran du fleuve Ucayali près de Pucallpa, au Pérou, avec une région d'intérêt créée à l'aide de l'outil de dessin de polygones.
Maintenant que notre région d'intérêt est définie et stockée dans une variable, nous pouvons l'utiliser pour calculer un histogramme de l'intensité du changement pour la ROI. Ajoutez le code suivant à la section "Calculations" du script.
La première instruction calcule un histogramme des valeurs d'intensité de variation des occurrences dans le ROI, en échantillonnant à une échelle de 30 m. La seconde imprime l'objet résultant dans l'onglet "Console" de l'éditeur de code. Vous pouvez développer l'arborescence des objets pour afficher les valeurs des buckets d'histogramme.
Les données numériques sont présentes, mais il existe de meilleures façons de visualiser les résultats.
Figure 8. Résultats de l'onglet "Console" affichant les valeurs d'histogramme de l'intensité de la variation des eaux de surface.
Pour améliorer cela, nous pouvons générer un histogramme à la place. Remplacez l'instruction qui définit l'objet d'histogramme par les instructions suivantes :
Ces instructions créent un objet de graphique d'histogramme, qui remplace l'arborescence d'objets d'histogramme dans l'onglet "Console" par un graphique. La méthode de graphique contient plusieurs arguments, y compris scale qui définit l'échelle spatiale, en mètres, à laquelle la région d'intérêt est échantillonnée, et minBucketWidth qui est utilisé pour contrôler la largeur des buckets d'histogramme.
Figure 9. Résultats de l'onglet "Console", affichant un histogramme de l'intensité de l'évolution des eaux de surface.
Vous pouvez explorer les valeurs du graphique de manière interactive en plaçant le curseur sur les barres de l'histogramme.
Script final
Le script complet de cette section est listé ci-dessous. Notez que le script inclut des instructions pour définir une géométrie de polygone (roi), qui est comparable à la géométrie que vous avez créée à l'aide des outils de géométrie de l'éditeur de code.
Dans la section suivante, vous explorerez plus en détail l'évolution de l'eau au fil du temps en travaillant avec la couche de transition de la classe d'eau.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/27 (UTC).
[null,null,["Dernière mise à jour le 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."]]