Waterbodies Long-Term Animations

Keywords: data used; waterbodies, data used; wofs_ls_summary_annual, data used; CHIRPS, data used; sentinel-2 geomedian, data used; landsat 5 & 7 geomedian, data used; landsat 8 & 9 geomedian

Background

The Digital Earth Africa Continental Waterbodies Monitoring Service identifies more than 700,000 water bodies from over three decades of satellite observations. This service maps persistent and seasonal water bodies and the change in their water surface area over time. Mapped water bodies may include, but are not limited to, lakes, ponds, man-made reservoirs, wetlands, and segments of some river systems. For more information on the waterbodies monitoring service, refer to the Datasets notebook.

Often, it makes sense to visualise changes in waterbodies through time using animations. Animations are a form of exploratory analysis that can help show whether there is an overall trend in water extent or ilustrate repeating seasonal patterns. This notebook demonstrates how to generate animations for the time series component of waterbodies alongside summary data from Water Observations from Space, rainfall data, and true-colour imagery.

Firstly, an animation showing annual changes in water extent is produced for a lake in Kenya with an increasing trend in water extent. Then, an animation is generated for Lake Chad in Nigeria which is known to have a decreasing trend.

Disclaimer: DE Africa Waterbodies Surface Area Change measures the wet surface area of waterbodies as estimated from satellites. This product does not measure depth, volume, purpose of the waterbody, nor the source of the water.

Description

This notebook demonstrates the generation of two animations for inspecting changes in water extent over several years, drawing on the DE Africa Waterbodies service.

Steps taken are:

  1. Loading and preparing annual time series, WOfS, and true-colour data.

  2. Creating an animation for annual changes in water extent.


Getting started

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

Load packages

Import Python packages that are used for the analysis.

[1]:
import matplotlib.pyplot as plt
import datacube
import matplotlib.dates as mdates
import numpy as np
import matplotlib.animation as animation

from deafrica_tools.plotting import display_map
from IPython.display import HTML
from deafrica_tools.spatial import xr_rasterize
from deafrica_tools.waterbodies import (
    get_geohashes,
    get_waterbodies,
    get_waterbody,
    get_time_series,
    display_time_series,
)
[2]:
dc = datacube.Datacube(app="Waterbody-anim")

Analysis parameters

This section defines the analysis parameters, including:

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

The default area is Lake Baringo in Kenya which has experienced an increase in extent over recent years and has previously been studied with Digital Earth Africa.

[3]:
# Set the central latitude and longitude
lat = 0.62
lon = 36.08

# Set the buffer to load around the central coordinates
buffer = 0.3

# Compute the bounding box coordinates
xlim = (lon - buffer, lon + buffer)
ylim = (lat + buffer, lat - buffer)

# Preview area on a map
display_map(xlim, ylim)
[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Getting data

The deafrica_waterbodies module allows you to query water bodies by location or geohash. For more background, see the waterbodies documentation and the waterbodies Datasets notebook.

List waterbody polygons in an area

We can get a list of waterbody polygons inside a bounding box of coordinates using get_waterbodies.

[4]:
# Create a bounding box from study area coordinates
bbox = (xlim[0], ylim[1], xlim[1], ylim[0])

# Select all water bodies located within the bounding box
polygons = get_waterbodies(bbox, crs="EPSG:4326")

The returned geodataframe includes all the water bodies which are located within the bounding box. This dataset contains metadata for each water body in the dataset, including the ID, UID, WB_UID, area, perimeter and time series. See the Waterbodies Historical Extent documentation for descriptions of each attribute.

Explore and select the polygon

Once the water body polygons are in memory, you can plot them directly, or explore them in an interactive window.

[5]:
# Explore the waterbody polygons located within the bounding box
polygons.explore()
[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Select geohash

Exploring the polygons above, we can see that our waterbody of interest, Lake Baringo, is represented by a single large polygon. There are numerous smaller polygons in the vicinity or immediately surrounding the lake. The geohash for the primary polygon (shown as uid when hovering the mouse) is sb1ekyxw88.

Getting time series data

[6]:
selected_waterbody_geohash = "sb1ekyxw88"

selected_waterbody = get_waterbody(selected_waterbody_geohash)

Get the wet surface area time series for the selected waterbody

For any given geohash or a polygon, we can also use the get_time_series() function to get various measures of the water body surface over time. See the Waterbodies Historical Extent documentation for descriptions of the different surface measures.

The function also calculates a rolling median of the water body surface wet percentage. This is used to visualise the overall trend in the surface wet percentage. The rolling median uses the last three observations to determine the median at a given date.

[7]:
# Get time series for the selected water body
selected_waterbody_timeseries = get_time_series(waterbody=selected_waterbody)

selected_waterbody_timeseries.head()
[7]:
area_wet_m2 percent_wet area_dry_m2 percent_dry area_invalid_m2 percent_invalid area_observed_m2 percent_observed percent_wet_rolling_median
date
1984-05-30 142439400.0 62.88 79190100.0 34.96 4910400.0 2.17 226539900.0 100.0 NaN
1984-06-15 147272400.0 65.01 79223400.0 34.97 44100.0 0.02 226539900.0 100.0 NaN
1984-07-01 147078900.0 64.92 79350300.0 35.03 110700.0 0.05 226539900.0 100.0 64.92
1984-07-17 147500100.0 65.11 78994800.0 34.87 45000.0 0.02 226539900.0 100.0 65.01
1984-12-08 132145200.0 58.33 83509200.0 36.86 10885500.0 4.81 226539900.0 100.0 64.92

Display the wet surface area time series for the selected waterbody

After loading the water body time series, we can use the display_time_series() function to create an interactive visualisation of the time series.

The visualisation shows the invalid percentage and the wet percentage.

Limited data availability prior to 2009 is evident, due to the combination of sensor presence (Landsat-8 was launced in 2013 and Landsat-9 in 2021) and data quality.

The increase in water extent from 2010 to present is clearly observable in the time series.

[8]:
display_time_series(selected_waterbody_timeseries)