This repository presents an efficient GEE-based solution for mapping water surface area time-series in waterbodies from Landsat and Sentinel-2 imagery.
While many solutions exist to map waterbodies, this toolkit presents the following advantages:
The development of this tool was supported through funding from the Australian Government (Murray-Darling Basin Authority).
The tool was developed jointly by the NSW Department of Climate Change, Energy, the Environment and Water and NGIS.
The toolkit is also catalogued in the SEED Portal as the remote-sensing-earth-observation-water-toolkit.
The tool is currently maintained by @ShiruiH and @kvos.
To use this tool you will need access to a Google Earth Engine (GEE) project. You can create one at https://signup.earthengine.google.com/. Then go to https://cloud.google.com/sdk/docs/install and install the gcloud CLI
. After you have installed it will automatically launch and let you authenticate with your GEE account (or personal gmail).
To install the Python environment, install Anaconda (https://www.anaconda.com/download/). Then open the Anaconda Prompt and type in the following commands:
conda create -n eowater
conda activate eowater
conda install -c conda-forge geopandas -y
conda install -c conda-forge earthengine-api scikit-image rasterio matplotlib notebook folium -y
Then type jupyter lab
and navigate to the notebooks in this repository.
Two downloading options are available:
Option #1: Download scene from USGS Earth Explorer
Visit USGS Earth Explorer and download a single scene for the required Sentinel-2 and/or Landsat tiles to cover your area of interest.
Option #2: Download scene from USGS Earth Explorer
Use the EE Code Editor to download a single scene for the required Sentinel-2 and/or Landsat tiles to cover your area of interest. Use the Download_original_tiles_S2.js and Download_original_tiles_Landsat.js, and specify the variable tile_list
.
01_Create_polygon_mask.ipynb: notebook to generate the polygon masks for Landsat and Sentinel-2 tiles using a waterbodies boundaries vector layer. A set of input polygon boundaries are provided in the repo for the NSW Northern Basin as an example in waterbodies_boundaries.geojson, courtesy of the National Resources Access Regulator (NRAR).
The inputs for this script is the Sentinel-2 and Landsat tiles downloaded from Step 1. The script creates a .tif
file for each tile with a mask where each individual polygon is assigned a different value, which allows the process to distinguish them at a raster level.
Once the polygon masks have been generated in Python, they need to be uploaded as cloud assets into GEE. You can follow the instructions below to perform this step. Two options are available, with different usage scnarios.
If only a few images need to be uploaded (e.g., fewer than 3), the Option #1 manual process is recommended. This method avoids the need to set up Cloud Storage access authentication.
For uploading a large number of images, the Option #2 automated process is more efficient.
3. Once uploaded, click on the asset and it should show up like in the screenshot below:
4. Click on Edit then on the PROPERTIES tab and Add property. Add a property called Tile with value 55JGH (or different tilename). This property is needed later on.
5. Repeat for the Landsat tiles, but add two properties, PATH and ROW with their respective values (example below for tile 090081).
6. Once all the individual tiles have been uploaded, click on NEW > Image Collection and create an image collection for Sentinel-2 (named it `Base_Sentinel2_tiles`) and for Landsat (name it `Base_Landsat_tiles`).
7. Then drag and drop all the invididual tiles into their respective image collection (Sentinel-2 or Landsat). The image collection should look as below (17 tiles in that example):
8. Finally, upload the image labels which were saved in [/outputs](/outputs). Click on NEW > CSV file and select the file `outputs/labels.csv` (or Landsat one, they are the same). Call the asset `Base_labels`.
You should get a table that relates each unique polygon id to an integer value, like shown below:
(Optional) If polygon masks in GEE Assets need to be removed and re-uploaded. Use 04_Reset_EE_asset_collection.ipynb to batch remove all tiles.
:warning: Check that you have these 3 assets uploaded:
Base_Sentinel2_tiles
: image collection of polygon masks for each tile of interest for Sentinel-2.Base_Landsat_tiles
: image collection of polygon masks for each tile of interest for Landsat.Base_labels
: table relating each polygon id to its unique label value in the masks.Now you are all setup to map water surface area time-series in GEE!
The scripts are found in GEE_scripts and can be copied into the Code Editor and run there. They will output a set of CSV files with the time-series of water surface area for each polygon. The following scripts are available:
The tileList
in the scripts needs to include only the available tiles in Base_Sentinel2_tiles
or Base_Landsat_tiles
.
(Optional) Additionally, there is a Python script WSA_scheduled_cloud_function.js that can be setup as a Cloud Function to process Sentinel-2, Landsat 9 and Landsat 8 imagery as a cron job.
05_Postprocess_timeseries.ipynb: notebook to postprocess the time-series of water surface area generated in GEE and includes the following steps:
Finally, the notebook also creates an interactive map where users can visualise the polygons and time-series at the same time (click on a polygon to visualise the time-series plot).
This can be a useful tool to monitor water resources in a catchment.
Having a problem? Post an issue in the Issues page (please do not email).
If you are willing to contribute, check out our todo list in the Projects page.
This section provides a list of references on this topic.