Raster.plot() or ds.rst.plot()

Raster.plot() or ds.rst.plot()#

RasterBase.plot(bands=None, ref=None, cmap=None, max_pixels='auto', vmin=None, vmax=None, alpha=None, title=None, cbar_title=None, add_cbar=True, ax=None, *, resampling=None, return_axes=False, savefig_fname=None, **kwargs)[source]#

Plot the raster.

Overloads:
  • self, bands (int | tuple[int, …] | None), ref (RasterLike | VectorLike | CRS | str | int | None), cmap (matplotlib.colors.Colormap | str | None), max_pixels (Literal[‘auto’] | int | None), vmin (float | int | None), vmax (float | int | None), alpha (float | int | None), title (str | None), cbar_title (str | None), add_cbar (bool), ax (matplotlib.axes.Axes | Literal[‘new’] | None), resampling (Resampling | str | None), return_axes (Literal[False]), savefig_fname (str | None), kwargs (Any) → None

  • self, bands (int | tuple[int, …] | None), ref (RasterLike | VectorLike | CRS | str | int | None), cmap (matplotlib.colors.Colormap | str | None), max_pixels (Literal[‘auto’] | int | None), vmin (float | int | None), vmax (float | int | None), alpha (float | int | None), title (str | None), cbar_title (str | None), add_cbar (bool), ax (matplotlib.axes.Axes | Literal[‘new’] | None), resampling (Resampling | str | None), return_axes (Literal[True]), savefig_fname (str | None), kwargs (Any) → tuple[matplotlib.axes.Axes, matplotlib.axes.Axes | None]

This method performs automatic subsampling to facilitate the plotting of large datasets out-of-memory, then wraps Matplotlib imshow to which keyword arguments are passed.

Parameters:
  • bands (int | tuple[int, …] | None) – Bands to plot, counting from 1 to self.count. Defaults to all bands.

  • ref (RasterLike | VectorLike | CRS | str | int | None) – Reference geospatial object or CRS to match. A reference object also sets the plotted axis limits to its bounds.

  • cmap (matplotlib.colors.Colormap | str | None) – Colormap to use. Defaults to matplotlib.rcParams['image.cmap'].

  • max_pixels (Literal[‘auto’] | int | None) – The default "auto" limits output to the Matplotlib axes width and height in display pixels, as set by the figure size and DPI. An integer limits the total number of plotted pixels, and None keeps the native grid size. This creates a temporary grid through reprojection and does not select a specific overview stored in the source file. See Rasterio’s overview documentation.

  • vmin (float | int | None) – Minimum value for the colorbar. Defaults to the plotted data minimum.

  • vmax (float | int | None) – Maximum value for the colorbar. Defaults to the plotted data maximum.

  • alpha (float | int | None) – Raster and colorbar transparency.

  • title (str | None) – Plot title.

  • cbar_title (str | None) – Colorbar label.

  • add_cbar (bool) – Whether to display a colorbar. Multi-band RGB(A) plots never add one.

  • ax (matplotlib.axes.Axes | Literal[‘new’] | None) – Matplotlib axes, "new" to create axes, or None to use the current axes.

  • resampling (Resampling | str | None) – Rasterio resampling method used when the display grid changes. Defaults to the configured reprojection method, except for boolean rasters whose reprojection uses nearest-neighbor resampling.

  • return_axes (bool) – Whether to return the image and colorbar axes.

  • savefig_fname (str | None) – Optional path at which to save the current figure.

Returns:

None, or the image axes and optional colorbar axes when return_axes=True.