Water Observations from Space (WOfS) d3b1c2d001324b83845fe12f66f7273e

Keywords: datasets; WOfS, data used; WOfS


Water Observations from Space (WOfS) are a suite of surface water products. They are generated using the WOfS classification algorithm on Landsat 8 satellite data. There are several WOfS products available for the African continent, as listed below:

Product Type


WOfS Annual Summary

The ratio (%) of wet to clear observations from each calendar year

WOfS All-Time Summary

The ratio (%) of wet to clear observations over all time

WOFLs (WOfS Feature Layers)

WOfS slices generated per scene

WOfS Filtered Summary (Under development)

All-time summary checked against the confidence layer

  • WOfS Annual/All-Time Summary: The percentage of time a pixel was classified as wet. This requires:

    • Total number of clear observations for each pixel: the number of observations that were clear (no cloud or shadow) for the selected time period. The classification algorithm then assigns these as either wet, or dry.

    • Total number of wet observation for each pixel: the number of observations that were clear and wet for the selected time period.

The WOfS Summary is calculated as the ratio of clear wet observations to total clear observations, expressed as a percentage.

\[\text{WOfS Summary} = \frac{\text{Number of Wet Observations}}{\text{Number of (Wet + Dry) Observations}} \times 100\]
  • WOFLs (WOfS Feature Layers): Individual water-classified images are called Water Observation Feature Layers (WOFLs), and are created in a 1-to-1 relationship with the input satellite data. Hence there is one WOFL for each satellite dataset processed for the occurrence of water. For more information on WOFLs, see the Applying WOfS bitmasking notebook.

  • WOfS Filtered Summary: The percentage of time a pixel was classified as wet, filtered using the confidence layer. The Filtered Summary is the WOfS Summary where areas with less than 10% confidence have been removed. This product is still under development for the African continent.


This notebook explains loading and using WOFLs to visualise WOfS over a chosen time period.

This notebook demonstrates how to: 1. Show WOfS for a single timestep using WOFLs for a selected time and place. 2. Show WOfS averaged over a selected time period. 3. Save a WOFL to a Cloud Optimised Geotiff (COG).

Getting Started

To run this analysis, run all the cells in the notebook, starting with the “Load packages” cell.

Load packages

%matplotlib inline

# Modules for the datacube
import datacube
from datacube.storage import masking
from datacube.utils import geometry
from datacube.utils.geometry import CRS
from datacube.utils.cog import write_cog
import numpy as np
import pandas as pd
import seaborn as sn
import xarray as xr
import sys

# Modules for plotting
import matplotlib.pyplot as plt

from deafrica_tools.datahandling import wofs_fuser, mostcommon_crs
from deafrica_tools.plotting import display_map

# Ignore datacube warnings (needs to be last import statement)
import warnings
warnings.filterwarnings('ignore', module='datacube')
/env/lib/python3.6/site-packages/datacube/storage/masking.py:8: DeprecationWarning: datacube.storage.masking has moved to datacube.utils.masking
/env/lib/python3.6/site-packages/geopandas/_compat.py:88: UserWarning: The Shapely GEOS version (3.7.2-CAPI-1.11.0 ) is incompatible with the GEOS version PyGEOS was compiled with (3.9.0-CAPI-1.16.2). Conversions between both will be slow.
  shapely_geos_version, geos_capi_version_string

Connect to the datacube

dc = datacube.Datacube(app="Intro_WOfS")

List of WOfS products available in Digital Earth Africa

pd.set_option('display.max_colwidth', None)

products = dc.list_products()
display_columns = ['name', 'description']
dc_products = products[display_columns]
name description
47 ga_ls8c_wofs_2 Historic Flood Mapping Water Observations from Space
49 ga_ls8c_wofs_2_annual_summary Water Observations from Space Annual Statistics
48 ga_ls8c_wofs_2_summary Water Observations from Space Full History Statistics

Analysis parameters

The following items are included in the “query” that defines what the datacube need to return.

  • lat, lon, buffer: center lat/lon and analysis window size for the area of interest

  • time: date range to fetch the scenes. The approximate time between two scenes is 16 days. If there is a location near a swathe boundary, it may be captured in two passes and so there could be two images within the 16 day period.

  • output_crs: the coordinate reference system of the query.

The default location is Lake Sulunga in Tanzania.

lat, lon =  -6.083, 35.184
buffer = 0.25

x = (lon-buffer, lon+buffer)
y =  (lat+buffer, lat-buffer)

# Create a reusable query
query = {
    'x': x,
    'y': y,
    'time': ('2015-01-01', '2019-03-20'),
    'resolution': (-30, 30)

output_crs = mostcommon_crs(dc=dc, product='ga_ls8c_wofs_2', query=query)
/env/lib/python3.6/site-packages/deafrica_tools/datahandling.py:673: UserWarning: Multiple UTM zones ['epsg:32637', 'epsg:32636'] were returned for this query. Defaulting to the most common zone: epsg:32636

View the selected location

# View the location
display_map(x=x, y=y)

WOfS Feature Layers (WOFLs)

WOFLs use bit flags to flag pixels as “wet” or otherwise. For more details on bitmasking with WOfS, see the Applying WOfS bitmasking notebook. Here, it is not necessary to directly call on the bit flags as we can use the selection wet=True to create the water mask, while dry=True gives the opposite. In this case, isel is used to select a single timestep, and shows the wet/dry pixels for that increment only.

# Load WOfS feature layers
wofls= dc.load(product = 'ga_ls8c_wofs_2',group_by="solar_day",fuse_func=wofs_fuser, output_crs = output_crs,**query)
Dimensions:      (time: 190, x: 1853, y: 1852)
  * time         (time) datetime64[ns] 2015-01-05T07:44:25.672915 ... 2019-03...
  * y            (y) float64 -6.451e+05 -6.451e+05 ... -7.006e+05 -7.006e+05
  * x            (x) float64 7.14e+05 7.14e+05 7.14e+05 ... 7.695e+05 7.695e+05
    spatial_ref  int32 32636
Data variables:
    water        (time, y, x) uint8 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1
    crs:           epsg:32636
    grid_mapping:  spatial_ref
# Show areas that are water in the 5th timestep
<matplotlib.collections.QuadMesh at 0x7f2f673ece80>

WOFL masks for a single timestep

wetwofl = masking.make_mask(wofls, wet=True)
<matplotlib.collections.QuadMesh at 0x7f2f67343828>
drywofl = masking.make_mask(wofls, dry=True)
<matplotlib.collections.QuadMesh at 0x7f2f673aeda0>

Percentage of time the lake was wet

To look at a summary of WOfS over multiple timesteps, it is advantageous to use the ga_ls8c_wofs_2_summary product. Feeding in the same query gives a frequency map for the time eriod defined previously.

freq = dc.load(product = 'ga_ls8c_wofs_2_summary', output_crs = output_crs,**query)
(freq.frequency*100).plot(figsize = (7,7))
<matplotlib.collections.QuadMesh at 0x7f2f6748c978>

Save WOFL to Cloud Optimised Geotiff (COG)

This method uses the datacube.utils.cog function write_cog,to export a simple single-band, single time-slice COG. COG stands for Cloud-Optimised-Geotiff. More detail on writing COGs can be found in the Exporting_GeoTIFFs notebook

# Write the WOFLs query to COG format

For more examples on how WOfS can be used for water resource management, also see the Water extent notebook in the DE Africa sandbox.

Additional information

License: The code in this notebook is licensed under the Apache License, Version 2.0. Digital Earth Africa data is licensed under the Creative Commons by Attribution 4.0 license.

Contact: If you need assistance, please post a question on the Open Data Cube Slack channel or on the GIS Stack Exchange using the open-data-cube tag (you can view previously asked questions here). If you would like to repoart an issue with this notebook, you can file one on Github.

Compatible datacube version:


Last Tested:

from datetime import datetime


Github Repository https://github.com/GeoscienceAustralia/wofs

Mueller, et al. 2015. Water observations from space: Mapping surface water from 25 years of Landsat imagery across Australia, Remote Sensing of Environment. https://doi.org/10.1016/j.rse.2015.11.003

GA, 2017. Water Observations from Space 2.1.5 Product Description. https://cmi.ga.gov.au/wo_25_2.1.5

GA, 2017. Water Observations from Space Statistics 25m 2.1.5, https://cmi.ga.gov.au/wo-stats_25_2.1.5

GA, 2017. Water Observations from Space Filtered Statistics 25m 2.1.5 Product Description https://data.dea.ga.gov.au/WOfS/filtered_summary/v2.1.0/Product%20Description.pdf