pysepal.mapping.visualization.set_viz_params#
- pysepal.mapping.visualization.set_viz_params(image, *, name='default', type=None, bands=None, min=None, max=None, palette=None, values=None, labels=None, inverted=None, index=0)[source]#
Embed SEPAL-convention visualization parameters as image properties.
This is the inverse of
get_viz_params(). SEPAL stores per-image visualization as flat propertiesvisualization_<index>_<key>; SepalMap reads them on display, and Earth Engine asset exports preserve them, so callers downstream (other SEPAL recipes, the Code Editor) see the styling automatically.- Parameters:
image (Image) – The
ee.Imageto annotate. A new image is returned; the original is not mutated.name (str) – Logical name of the visualization (e.g.
"default"). Stored asvisualization_<index>_name.type (str | None) – Visualization type — one of
"continuous","categorical","rgb","hsv". Inferred by SepalMap when omitted, based on the number of bands.bands (Sequence[str] | None) – Band names targeted by the visualization. Single-band for
continuous/categorical, three bands forrgb/hsv.min (float | Sequence[float] | None) – Per-band minimum value(s). Scalar or sequence; both stored as a comma-separated string.
max (float | Sequence[float] | None) – Per-band maximum value(s). Same rules as
min.palette (str | Sequence[str] | None) – Hex color palette. Sequence of
#RRGGBBor a pre-comma-joined string.values (Sequence[int | float] | None) – For
categoricalonly — the discrete pixel values that the palette maps to. Preserves non-consecutive class codes.labels (Sequence[str] | None) – Per-value human-readable labels (used in legends).
inverted (Sequence[bool] | None) – Per-band inversion flags.
index (int) – Slot index in the property name. Use distinct indices when attaching multiple named visualizations to the same image.
- Returns:
A new
ee.Imagecarrying the visualization properties.- Return type:
Image
Example
>>> styled = set_viz_params( ... classified, ... name="loss_year", ... type="categorical", ... bands=["classification"], ... palette=["#ffff00", "#8b0000", "#d3d3d3"], ... values=[1, 25, 30], ... labels=["loss 2001", "loss 2025", "non forest"], ... )