Mapping island coastal change using NDWI and Google Earth Engine

Part 1: Calculate the coastal change of Aruba

Using satellite data, calculate the change in Aruba’s coastline using NDWI

  1. Open the code and save it to your account.
  1. Read through the code.
  • The code has comments that explain what each part does, take a minute to read through the parts in green
  1. Note the dates, threshold, region, and buffers.
  • Dates – On lines 2-3, we have the start and end dates set to the beginning and end of 2021. This means that the code looks at all of the images taken by the Sentinel 2 satellite during that year.
  • Threshold – On line 6, there is a value called “threshold”. NDWI is an index that can be calculated from satellite image bands to assess the presence of water. The threshold is where we draw the line, where we decide that anything higher is water, and anything lower is not water. You can leave this at 0.3 for now, but you can try different numbers here to see what happens. For more details check out our GIS session notes here: and read section 3.1.1 in the methods section of this paper by Du et al:
  • Region – On line 9 we import the feature collection that contains the shape of our island of interest, in this case it’s Aruba. We want to end up with the geometry of the shape, not a feature or feature collection, so depending on where you get this from you might need to play with this line of code so we end up with the right thing. For example, if you have your island outline as an import entry at the top of your code, then you might be able to use line 12.
  • Buffers – On lines 15-16 we define a buffer around the coast. The aim of this is to include a bit of the ocean, to be sure we include any part of it that could have been land at some point. On the other side, we want to use a buffer inland to make sure we include any land which could have been ocean at some point, but also to leave out any inland water like lakes or dams or freshwater wetlands and marshes, since those can change year to year for different reasons that don’t represent a changing coastline.
  1. Run the code.
  • Run the code by clicking the “Run” button
  • If you have any typos in your code it won’t work, so figure out what those are if you have them
  • If it works right, you’ll see the NDWI map pop up on top of Aruba, and a number will come up on the right under “Console”. This number is the area of water (NDWI>threshold) around the coastal section of the map in square meters. This number isn’t very helpful by itself, so we need to write it down and compare it with another time period.
  • Change your dates to another period and run the code again
  • Compare the new number with the old one

Part 2: Calculate the coastal change on another island

Change the code to fit your island of interest and see how the coastline changes

  1. Copy the above code into a new project.
  • Using the code from Part 1 above, click “Save as” and give it a new name, something like islandCoast-myIsland
  1. Import your island into the code.
  • Adjust line 9 or use line 12  to import your island instead of Aruba
  • If your island is very small or narrow and doesn’t include any inland water areas, you might need to uncomment line 66 of the code
  • You can also adjust the zoom level on line 76 so that the map loads your island at a reasonable size. If you increase it from its current value of 11 it will zoom in closer, for islands smaller than Aruba. If you decrease it, it will zoom out for bigger islands.
  • Click Run to make sure you don’t get an error related to the region, otherwise you might need to adjust this line to properly import the geometry property of your island.
  1. Run the code on your island.
  • When it runs, you should see the map move to your island and display the NDWI
  • Before we start writing down numbers, double check that the buffer values we set are good.
  • To do this, in the map area click on the Layers box and activate the two buffer layers, and deactivate the NDWI layer. Then click on Satellite to see the satellite imagery background.
  • Now zoom in to your island, and inspect the area around the coast to make sure that the outer, yellow buffer zone includes all of the land, and that the red inner buffer zone stays inside the coast, but doesn’t include any inland bodies of water.
  • If necessary, adjust the buffer distance on lines 15-16
  • Click the “Save” button, then click the “Run” button to see how it goes
  • If everything works, change the dates and run it again
  • Do this for a few different time periods, so that you can see how the coastline is changing over time.


GIS = Geographical Information System

This is the term for spatial data — collecting, storing, and reading information about a space — often including tools like maps, satellite images, GPS, and software to combine and analyze things.

GEE = Google Earth Engine

This is a tool that enables us to work with GIS data. It works using code to access and analyze data derived from satellite images or mapping done on the ground. You can load pictures of Aruba taken by NASA satellites, or put in your own map you made using your phone, and then compare or calculate.

NDWI = Normalized Difference Water Index

NDWI is an index that can be calculated from satellite image bands to assess the presence of water. There are two main types, one which indicates how much moisture is present in soil or vegetation, and one which indicates the presence of liquid water on the surface. For mapping the coast, we’re interested in this second option, where we can basically use satellite images of the beach to map where the ocean starts. The NDWI calculation gives a number that ranges from -1 to 1, where higher numbers result from areas with water due to the difference in its absorption and radiation of different wavelengths of light. A threshold of about 0.2 or 0.3 is usually used, where we say any pixels in an image with an NDWI higher than that are surface water, and anything lower is not surface water.