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].- Parameters
*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.out_file (
Union
[str
,Path
,None
]) – Path to save figure if notNone
.vertical_layout (
bool
) – Produces a vertical array of plots ifTrue
, horizontal ifFalse
(default).figsize (
float
) – Print size of the horizontal axis of the plot (passed tomatplotlib
). The vertical size is calculated automatically.spacing (
float
) – Spacing between raster plots.cmaps (
Union
[str
,List
[str
]]) – Colormap to use for singleband plots, or list of colormaps (applied respectively). Must contain validmatplotlib
colormaps [2]. For rasters with multiple (3 or more) bands, this argument is ignored and RGB plots are produced.dpi (
int
) – DPI of the figure.nodata (
Optional
[List
[Union
[int
,float
]]]) – Nodata value or list of values respective to each raster. IfNone
and*rasters
contains file paths,nodata
will be inferred from raster source.vmin (
Optional
[List
[Union
[int
,float
]]]) – Minimum value to clip data.vmax (
Optional
[List
[Union
[int
,float
]]]) – Maximum value to clip data.perc_clip (
bool
) – Clips rasters with percentiles ifTrue
.perc_min (
List
[Union
[int
,float
]]) – Minimum percentile to clip with ifperc_clip=True
.perc_max (
List
[Union
[int
,float
]]) – Maximum percentile to clip with ifperc_clip=True
.
References
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', >>> )