dea_tools.landcover
Plotting and animating Digital Earth Australia Land Cover data.
License: The code in this notebook is licensed under the Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0). Digital Earth Australia data is licensed under the Creative Commons by Attribution 4.0 license (https://creativecommons.org/licenses/by/4.0/).
Contact: If you need assistance, please post a question on the Open Data Cube Discord chat (https://discord.com/invite/4hhBQVas5U) or on the GIS Stack Exchange (https://gis.stackexchange.com/questions/ask?tags=open-data-cube) using the open-data-cube tag (you can view previously asked questions here: https://gis.stackexchange.com/questions/tagged/open-data-cube).
If you would like to report an issue with this script, you can file one on GitHub (GeoscienceAustralia/dea-notebooks#new).
Last modified: March 2025
Functions
|
Gets colour scheme dictionary given the measurement of interest |
|
Creates an animation of DEA Landcover though time beside corresponding stacked plots of the landcover classes. |
|
Takes a colour scheme dictionary and returns colormap for matplotlib |
|
Adds a new colorbar with appropriate land cover colours and labels. |
|
Plot a single land cover measurement with appropriate colour scheme. |
- dea_tools.landcover.get_colour_scheme(measurement)[source]
Gets colour scheme dictionary given the measurement of interest
- dea_tools.landcover.lc_animation(da, file_name='default_animation', measurement=None, stacked_plot=False, colour_bar=False, animation_interval=500, out_width=20, dpi=150, font_size=15, label_size=15, label_ax=True)[source]
Creates an animation of DEA Landcover though time beside corresponding stacked plots of the landcover classes. Saves the animation to a file and displays the animation in notebook.
- Parameters:
da (xarray.DataArray) – An xarray.DataArray containing a multi-date stack of observations of a single landcover level.
file_name (string, optional.) – string used to create filename for saved animation file. Default: “default_animation” code adds .gif suffix.
measurement (string, optional) – Name of the DEA land cover classification to be plotted. Passed to _legend_colourmap to specify which colour scheme will be used. If non provided, reads data array name from da to determine.
stacked_plot (boolean, optional) – Determines if a stacked plot showing the percentage of area taken up by each class in each time slice is added to the animation. Default: False.
colour_bar (boolean, Optional) – Determines if a colour bar is generated for the stand alone animation. This is NOT recommended for use with level 4 data. Does not work with stacked plot. Default: False.
animation_interval (int , optional) – How quickly the frames of the animations should be re-drawn. Default: 500.
out_width (integer, optional) – Specifies the desired width of the output plot in inches. The height of the plot is scaled accordingly to maintain the correct aspect ratio of the data
dpi (int, optional) – Stands for ‘Dots Per Inch’. Passed to the fuction that saves the animation and determines the resolution. A higher number will produce a higher resolution image but a larger file size and slower processing. Default: 150.
font_size (int, optional.) – Controls the size of the text on the axes and colour bar. Default: 15.
label_size (int, optional.) – Controls the size of the text which indicates the year displayed. Default: 15.
label_ax (boolean, optional) – Determines if animation plot should have tick marks and numbers on axes. Also removes white space around plot. default: True
- Return type:
A GIF (.gif) animation file.
- dea_tools.landcover.lc_colourmap(colour_scheme)[source]
Takes a colour scheme dictionary and returns colormap for matplotlib
- Returns:
cmap (matplotlib colormap) – Matplotlib colormap containing the colour scheme for the specified DEA Land Cover measurement.
norm (matplotlib colormap index) – Matplotlib colormap index based on the discrete intervals of the classes in the specified DEA Land Cover measurement. Ensures the colormap maps the colours to the class numbers correctly.
- dea_tools.landcover.make_colourbar(fig, ax, measurement, labelsize=10, horizontal=False, animation=False)[source]
Adds a new colorbar with appropriate land cover colours and labels.
For DEA Land Cover Level 4 data, this function must be used with a double plot. The ‘ax’ should be on the left side of the figure, and the colour bar will added on the right hand side.
- Parameters:
fig (matplotlib figure) – Figure to add colourbar to
ax (matplotlib ax) – Matplotlib figure ax to add colorbar to.
measurement (string) – name of layer or descriptor of interest
labelsize (int) – size of labels of colourbar
- Return type:
matplotlib colorbar in its own colour axis
- dea_tools.landcover.plot_land_cover(data, labelsize=10, year=None, measurement=None, out_width=15, cols=4)[source]
Plot a single land cover measurement with appropriate colour scheme.
- Parameters:
data (xarray.DataArray) – A dataArray containing a DEA Land Cover classification.
year (int, optional) – Can be used to select to plot a specific year. If not provided, all time slices are plotted.
measurement (string, optional) – Name of the DEA land cover classification to be plotted. Passed to _legend_colourmap to specify which colour scheme will be used. If non provided, reads data array name from da to determine.
out_width (integer, optional) – Specifies the desired width of the output plot in inches. The height of the plot is scaled accordingly to maintain the correct aspect ratio of the data
cols (integer, optional) – Sets number of columns if multiple time steps are visualised
- Return type:
Matplotlib image