Exporting high quality satellite images¶
Keywords: widgets, interactive, plotting
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 also represents a powerful tool for visualisation. Images taken by satellites can help explain 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 data 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 1984. More recently, the Copernicus Sentinel-2 mission has provided even higher resolution imagery as frequently as every 5 days since 2017.
This notebook provides an interactive tool for selecting, loading, processing and exporting satellite imagery as a high quality image file. 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.
The tool supports Sentinel-2 and Landsat data, creating True and False colour images.
To run this analysis, run all the cells in the notebook, starting with the “Load packages” cell.
Import Python packages used for the analysis.
%matplotlib inline from deafrica_tools.app.imageexport import select_region_app, export_image_app
The following cell sets important required parameters used to plot and select satellite imagery on the interactive map.
date: The exact date used to display imagery on the map (e.g.
satellites: The satellite data to be shown on the map. Five options are currently supported:
Data from the Landsat 8 optical satellite
Data from the Landsat 7 optical satellite
Data from the Landsat 5 optical satellite
Data from the Sentinel-2A and 2B optical satellites
Data from the Sentinel-2 annual geomedian
If running the notebook for the first time, keep the default settings below. This will demonstrate how the analysis works and provide meaningful results.**
If passing in ``’Sentinel-2 geomedian’``, ensure the ``date`` looks like this: ``’<year>-01-01’``
# Required image selection parameters date = '2020-01-30' satellites = 'Sentinel-2'
Select location on a map¶
Run the following cell to plot the interactive map that is used to select the area to load and export satellite imagery.
Draw a rectangle or
Draw a polygon 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
done button on the top right of the map.
To keep load times reasonable, select an area smaller than 10000 square kilometers in size (this limit can be overuled by supplying the
size_limitparameter in the
selection = select_region_app(date=date, satellites=satellites, size_limit=10000)
The optional parameters below allow you to fine-tune the appearance of your output image.
style: The style used to produce the image. Two options are currently supported:
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.
resolution: The spatial resolution to load data. 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
resolution = (-100, 100)) can be useful for loading large spatial extents.
vmin, vmax: The minimum and maximum surface reflectance values used to clip the resulting imagery to enhance contrast.
percentile_stretch: A tuple of two percentiles (i.e. between 0.00 and 1.00) that can be used to clip the imagery to optimise the brightness and contrast of the image. If this parameter is used,
vmaxwill have no effect.
power: 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.
image_proc_funcsAn optional list containing functions that will be applied to the output image. This can include image processing functions such as increasing contrast, unsharp masking, saturation etc. The function should take and return a
[y, x, bands].
standardise_name: Whether to export the image file with a machine-readable file name (e.g.
If running the notebook for the first time, keep the default settings below. This will demonstrate how the analysis works and provide meaningful results.
# Optional image export parameters style = 'True colour' # 'False colour' resolution = None vmin, vmax = (0, 2000) percentile_stretch = None power = None image_proc_funcs = None output_format = "jpg" standardise_name = False
Once you are happy with the parameters above, run the cell below to load the satellite data and export it as an image:
# Load data and export image export_image_app( style=style, resolution=resolution, vmin=vmin, vmax=vmax, percentile_stretch=percentile_stretch, power=power, image_proc_funcs=image_proc_funcs, output_format=output_format, standardise_name=standardise_name, **selection )
Exporting image to Sentinel-2A - 2020-01-30 - Bitou Local Municipality, Western Cape - True colour, 10 m resolution.jpg. This may take several minutes to complete... Finished exporting image.
Downloading exported image¶
The image export will be completed when
Finished exporting image appears above, and a preview of your image is shown below the map.
The high resolution image file generated above 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:
Sentinel-2A - 2020-01-30 - Bitou Local Municipality, Western Cape - True colour, 10 m resolution
If you are using the DE Africa Sandbox, you can download the image to your PC by right clicking on the image file and selecting
When you are done, return to the Analysis parameters section, modify some values and rerun the analysis. For example, you could try:
"Landsat"to export a Landsat image instead of Sentinel-2.
"False colour"to export a false colour view of the landscape that highlights growing vegetation and water.
Specify a custom resolution, e.g.
resolution = (-1000, 1000).
Experiment with the
powerparameters to alter the appearance of the resulting image.
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 report an issue with this notebook, you can file one on
from datetime import datetime datetime.today().strftime('%Y-%m-%d')