eumap.plotter.plot_rasters

plot_rasters(*rasters, out_file=None, vertical_layout=False, figsize=10, spacing=0.01, cmaps='Spectral', titles=[], dpi=150, nodata=None, vmin=None, vmax=None, perc_clip=False, perc_min=2, perc_max=98)[source]

Plots data from one or more rasters.

Preserves pixel aspect ratio, removes axes and ensures transparency on nodata.

Uses matplotlib.pyplot.imshow [1].

param *rasters

List of rasters, passed as either data or file paths. If 3D (multiband) data is passed (as numpy array(s)), the first axis of the array must correspond to the band index.

param out_file

Path to save figure if not None.

param vertical_layout

Produces a vertical array of plots if True, horizontal if False (default).

param figsize

Print size of the horizontal axis of the plot (passed to matplotlib). The vertical size is calculated automatically.

param spacing

Spacing between raster plots.

param cmaps

Colormap to use for singleband plots, or list of colormaps (applied respectively). Must contain valid matplotlib colormaps [2]. For rasters with multiple (3 or more) bands, this argument is ignored and RGB plots are produced.

param titles

Titles to produce for each plot.

param dpi

DPI of the figure.

param nodata

Nodata value or list of values respective to each raster. If None and *rasters contains file paths, nodata will be inferred from raster source.

param vmin

Minimum value to clip data.

param vmax

Maximum value to clip data.

param perc_clip

Clips rasters with percentiles if True.

param perc_min

Minimum percentile to clip with if perc_clip=True.

param perc_max

Maximum percentile to clip with if perc_clip=True.

References

[1] Matplotlib imshow

[2] Matplotlib colormaps

Examples

>>> from eumap import plotter
>>> import numpy as np
>>>
>>> singleband = np.random.randint(0, 255, [5, 5])
>>> multiband = np.random.randint(0, 255, [3, 5, 5])
>>>
>>> plotter.plot_rasters(
>>>     singleband,
>>>     multiband,
>>>     titles=['single band', 'RGB'],
>>>     figsize=4,
>>>     cmaps='Greens',
>>> )