odc.geo.xr.ODCExtensionDa.colorize

ODCExtensionDa.colorize(cmap=None, attrs=None, *, clip: bool = False, vmin: Optional[float] = None, vmax: Optional[float] = None, robust: Optional[bool] = None) DataArray

Apply colormap to data.

There are two modes of operation:

  • Map categorical values from x to RGBA according to cmap lookup table.

  • Interpolate into RGBA using matplotlib colormaps (needs matplotlib installed)

Note

When using matplotlib colormaps with Dask inputs one must configure vmin/vmax to ensure all chunks are colorized consistently.

Parameters
  • x (Any) – Input xarray data array (can be Dask)

  • cmap – Lookup table cmap[x] -> RGB(A) or matplotlib colormap

  • vmin (Optional[float]) – Valid range to colorize

  • vmax (Optional[float]) – Valid range to colorize

  • robust (Optional[bool]) – Use percentiles for clamping vmin=2%, vmax=98%

  • attrs – xarray attributes table, if not supplied input attributes are copied across

  • clip (bool) – If True clip values from x to be in the safe range for cmap.

Return type

DataArray