English | Deutsch
Plot functions¶
The plot function of each data type is documented on the page of the data type (All functions). This
page describes what they share, and plot_raster(), which draws any GeoTIFF.
What is drawn¶
Pixels without data are transparent.
The axes show the coordinates of the file: degrees or metres. For longitude and latitude the map is corrected for the shorter degrees of longitude (Grids and time).
A file with the wrong number of bands (for example a true-colour file passed to
plot_ndvi) raises aValueErrorthat names the file and points toplot_raster.
Any GeoTIFF¶
- cdec.plot_raster(file_path, *, band=1, cmap='viridis', vmin=None, vmax=None, label=None, title=None, colorbar=True, ax=None, show=None)[source]¶
Draw any GeoTIFF, decided by its format.
A file with three 8-bit bands is a colour picture (for example the true-colour image) and is drawn as it is.
Everything else is drawn as one band of numbers with a colour bar.
The function cannot know what the numbers mean. For the data types of this package use the matching function (
plot_ndvi,plot_dem, …), which sets a suitable colour map and value range.- Parameters:
file_path (str | Path) – The GeoTIFF to draw, for example the file written by a
download_*function.band (int) – Which band to draw (1 is the first). Ignored for colour pictures.
cmap (str) – Name of a matplotlib colour map, see https://matplotlib.org/stable/users/explain/colors/colormaps.html
vmin (float | None) – Values at the two ends of the colour map.
Nonetakes the smallest and largest value of the band. Fix them (for examplevmin=-1, vmax=1for NDVI) to compare several images with the same colours.vmax (float | None) – Values at the two ends of the colour map.
Nonetakes the smallest and largest value of the band. Fix them (for examplevmin=-1, vmax=1for NDVI) to compare several images with the same colours.label (str | None) – Text next to the colour bar. Default: the description stored in the file, if there is one.
title (str | None) – Title of the plot.
colorbar (bool) – Draw a colour bar.
ax (Axes | None) – A matplotlib
Axesto draw into.Nonecreates a new figure.show (bool | None) – Call
plt.show()at the end. The default (None) shows the figure only if the function created it, so a figure that you put together yourself is not shown too early.
- Returns:
The axes with the plot, for further changes.
- Return type:
matplotlib.axes.Axes