odc.geo.xr.colorize

odc.geo.xr.colorize(x, cmap=None, attrs=None, *, clip=False, vmin=None, vmax=None, robust=None)[source]

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