Exporting high quality satellite images

Keywords: widgets, interactive, plotting

Contexte

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.

Description

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.


Getting started

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

Load packages

Import Python packages used for the analysis.

[1]:
%matplotlib inline

from deafrica_tools.app.imageexport import select_region_app, export_image_app

Select imagery

Analysis parameters

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. date='1988-01-01').

  • satellites: The satellite data to be shown on the map. Five options are currently supported:

« Landsat-8 »

Data from the Landsat 8 optical satellite

« Landsat-7 »

Data from the Landsat 7 optical satellite

« Landsat-5 »

Data from the Landsat 5 optical satellite

« Sentinel-2 »

Data from the Sentinel-2A and 2B optical satellites

« Sentinel-2 geomedian »

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”``

[2]:
# 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.

Select the 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_limit parameter in the select_region_app function below).

[3]:
selection = select_region_app(date=date,
                              satellites=satellites,
                              size_limit=10000)

Export image

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:

« True colour »

Creates a true colour image using the red, green and blue satellite bands

« False colour »

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, vmin and vmax will 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_funcs An 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 numpy.ndarray with shape [y, x, bands].

  • standardise_name: Whether to export the image file with a machine-readable file name (e.g. sentinel-2a_2020-01-30_bitou-local-municipality-western-cape_true-colour-10-m-resolution.jpg)

    If running the notebook for the first time, keep the default settings below. This will demonstrate how the analysis works and provide meaningful results.

[4]:
# 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:

[5]:
# 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
)

Client

Cluster

  • Workers: 1
  • Cores: 4
  • Memory: 28.14 GB

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.
../../../_images/sandbox_notebooks_Real_world_examples_Exporting_satellite_images_14_2.png

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 Download.

Prochaines étapes

When you are done, return to the Analysis parameters section, modify some values and rerun the analysis. For example, you could try:

  • Change satellites to "Landsat" to export a Landsat image instead of Sentinel-2.

  • Modify style to "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 vmin, vmax, percentile_stretch and power parameters to alter the appearance of the resulting image.


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 report an issue with this notebook, you can file one on Github.

Last Tested:

[6]:
from datetime import datetime
datetime.today().strftime('%Y-%m-%d')
[6]:
'2021-10-07'