geomappy.plotting.raster.plot_classified_raster

geomappy.plotting.raster.plot_classified_raster(m: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], *, levels: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, colors: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, labels: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, cmap: str | Colormap = 'Set1', nan_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = None, ax: Axes | None = None, legend: str | LegendCreator | None = 'colorbar', legend_ax: Axes | None = None, **kwargs) tuple[AxesImage, Colorbar | Legend | None]

Plot a 2D raster with discrete classes.

Parameters:
  • m (array_like) – Input 2D array representing the raster data.

  • levels (array_like, optional) – Bins for classification (as used by numpy.digitize()). Defaults to unique values in m.

  • labels (array_like, optional) – Labels for the classes. Defaults to levels.

  • colors (array_like, optional) – Colors for each class. Defaults are generated from cmap.

  • cmap (str or matplotlib.colors.Colormap, optional) – Colormap to use if colors is not provided. Default is ‘Set1’.

  • nan_color (ColorType, optional) – Color for NaN values. Default is white.

  • ax (matplotlib.axes.Axes, optional) – Axes to draw the plot. If not provided, a new figure and axes are created.

  • legend ({'colorbar', 'legend', None}, optional) – Type of legend to draw. Default is ‘colorbar’.

  • legend_ax (matplotlib.axes.Axes, optional) – Axes for the legend. If not provided, it is created automatically.

  • **kwargs – Additional keyword arguments passed to matplotlib.pyplot.imshow().

Returns:

Notes

When plotting on a cartopy.mpl.geoaxes.GeoAxes, the extent and transform should be provided in kwargs if the raster does not perfectly align with the projection.