Exporting satellite imagery animations¶
Keywords: data used; landsat 5, data used; landsat 7, data used; landsat 8, data used; landsat 9, data used; sentinel 2, animation,
Most of the case studies in this repository focus on quantitatively analysing satellite data to obtain insights into Africa’s changing environment. However, satellite imagery can also be used as a powerful tool for visualisation, particularly within dynamic environments that have changed significantly over the past ~30 years.
Animations produced from satellite images can help explain dynamic physical processes, highlight change over time, or provide valuable context to better understand the impacts of recent environmental events such as flooding or fire. Satellite animations can also be processed to create images of the landscape based on invisible wavelengths of light (e.g. false colour images), allowing us to obtain richer insights into features and processes that would otherwise be invisible to the human eye.
Digital Earth Africa use case¶
Digital Earth Africa provides over three decades of satellite imagery across the entire continent of Africa. Satellite data from the NASA/USGS Landsat program allow us to produce fortnightly images of Africa’s diverse natural and artificial landscapes at any time since 1986. More recently, the Copernicus Sentinel-2 mission has provided even higher resolution imagery as frequently as every 5 days since 2015.
This notebook provides an interactive tool for selecting, loading, processing and exporting satellite imagery as high quality animated MP4 and GIF files. This can be used in combination with the interactive Digital Earth Africa Maps platform to identify an image of interest, then download it using this notebook for use in other applications.
To run this analysis, run all the cells in the notebook, starting with the “Load packages” cell.
Import Python packages used for the analysis.
from deafrica_tools.app import animations
Digital Earth Africa satellite imagery animation app¶
animations.animation_app() cell below to launch the interactive application that is used to select the area to load and export satellite imagery animations.
On the left of the map, you will see a date selector, and a list of satellite imagery you can load:
Data from the Landsat 5, 7, 8 and 9 satellites
Data from the Sentinel-2A and 2B satellites
Satellite imagery can be viewed and exported in two colour styles:
Creates a true colour image using the red, green and blue satellite bands
Creates a false colour image using short-wave infrared, infrared and green satellite bands.
You can also modify the brightness and contrast of the output image by dragging the
Colour percentile stretch slider, and select the output image format from
.MP4 (smaller file sizes, higher quality, fast processing speeds) to
.GIF (larger file sizes, lower quality, slower processing).
Apply rolling median box to produce a smooth animation that reduces the influence of cloud and noise. The larger the rolling median window, the smoother the output (at the expense of potentially removing short-lived events from the animation).
Selecting a location to export¶
Zoom into the map to a location you wish to animate. Select the
Draw a rectangle tool on the left of the map, and draw a shape around the area you are interested in. When you are ready, press the green
Generate animation button on the bottom left to start the animation generation.
To keep load times reasonable, the app is restricted to image exports smaller than 50000 hectares in size. This limit can be overuled in the
The animation tool supports several advanced features. To access these, click on the
Advanced tab in the menu to the left of the map to expand it: *
Frame interval: The frame rate used to animate the satellite data. Values are in milliseconds - larger values will produce a longer, slower animation. *
Resolution: The spatial resolution to load data (in metres). By default, the tool will automatically set the best possible resolution depending on the satellites selected (i.e. 30 m
for Landsat, 10 m for Sentinel-2). Increasing this (e.g. to
100) can be useful for loading large spatial extents. *
Width of output animation: The width of the animation MP4 or GIF file in pixels. This can be used to produce a HD video, but won’t increase the resolution of the input satellite imagery (setting a high value will produce a larger animation, but may introduce unwanted pixelation). *
Apply temporal resampling: Whether to combine multiple satellite images into time
period median composite images. Available options are
Mask out cloudy pixels: Whether to mask out cloudy pixels with
nodata to remove them from the animation. This is best used in combination with a rolling median or temporal resampling, as otherwise it will introduce large areas of black
nodata pixels in the animation. *
Add DE Africa Coastlines overlay: Whether to add annual shoreline vectors from the Digital Earth
Africa Coastlines product as an overlay on top of the animation. *
Apply power transformation: Raises imagery by a power to reduce bright features and enhance dark features. This can add extra definition over areas with extremely bright features like snow, beaches or salt pans. *
Apply unsharp masking Whether to apply unsharp masking to increase the sharpness of the output image. If activated, you can specify both the radius (in pixels) and the amount/strength of the sharpening. *
Override maximum size limit: Whether to override the app’s default 500 square km area limit. This can be used to load larger areas of satellite imagery, but should be used with caution as it can lead to memory issues or crashes.
If running the notebook for the first time, keep the default settings above. This will demonstrate how the analysis works and provide meaningful results.
Downloading exported animation¶
The animation will be completed when
Finished exporting animation appears, and a preview of your animation is shown below the map.
The animation file (MP4 or GIF) will be saved to the same location you are running this notebook from (e.g. typically
Real_world_examples). In JupyterLab, use the file browser to locate the image file with a name in the following format:
If you are using the DE Africa Analysis Sandbox, you can download the animation to your PC by right clicking on the image file and selecting
When you have exported your first animation, modify some parameters and rerun the analysis by clicking
Generate animation. For example, you could try:
Applying a rolling median to produce a smooth animation that highlights long-term change over time.
Generate an animation for new dates using the date selectors.
Changing the satellite data to
"Sentinel-2"to export a Sentinel-2 animation instead of Landsat.
"False colour"style to export a false colour view of the landscape that highlights growing vegetation and water.
Specify a custom resolution in the
Experiment with different colour percentile stretches and the
Advancedtab unsharp masking and power transformation functionality to alter the appearance of the resulting image.
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 report an issue with this notebook, you can file one on
Compatible datacube version:
import datacube print(datacube.__version__)
from datetime import datetime datetime.today().strftime('%Y-%m-%d')