colormap#

geodesic.boson.colormap(*, asset, band, colormap_name='magma', lookup_table=None, min=None, max=None, rescale=False, no_data_value=None, no_data_values=None, no_data_after_rescale=False, asset_name='colormap')[source]#

Apply a colormap to the pixels data from an existing asset in the dataset.

Parameters:
  • asset (str) – asset to apply the colormap to

  • band (int | str) – band to apply the colormap to

  • colormap_name (str) – name of the colormap to apply. Defaults to “magma”.

  • lookup_table (List[List[int]] | None) – lookup table to apply. Defaults to None. This can be used to provide a custom colormap via a lookup table. In this case, this should be a list of lists where each sublist is a color, including the alpha channel. For instance, [[0, 0, 0, 255], [255, 255, 255, 255]] would create a colormap that goes from black to white in two steps, splitting values below 0,5 to black and above to white.

  • min (float | None) – minimum value of the colormap. Valid only if rescale is True. Defaults to None.

  • max (float | None) – maximum value of the colormap. Valid only if rescale is True. Defaults to None.

  • rescale (bool) – whether to rescale the colormap to the min and max values. If min/max are None, statistics of the dataset (if available) will be used, otherwise the values of the current response will be used. Defaults to False.

  • no_data_value (float | None) – value to use for pixels with no data. These values will be transparent. Defaults to None.

  • no_data_values (List[float] | None) – list of values to use for pixels with no data. These values will be transparent. Prefer this to no_data_value as this will take precedence.

  • no_data_after_rescale (bool) – whether to set the no data value on rescaled values instead of prior to rescaleing. Defaults to False.

  • asset_name (str) – name of the asset to create. Defaults to “colormap”.

Examples

>>> # Apply the magma colormap to the rasterized band of the asset "rasterized"
>>> colormap_transform = colormap(asset="rasterized", band="rasterized", min=0, max=1000)