diff --git a/pccommon/render.py b/pccommon/render.py index 7678f46..6f936da 100644 --- a/pccommon/render.py +++ b/pccommon/render.py @@ -77,6 +77,15 @@ COLLECTION_RENDER_CONFIG = { mosaic_preview_coords=[37.2141, -104.2947], minzoom=9, ), + "chloris-biomass": DefaultRenderConfig( + assets=["data"], + render_params={"colormap_name": "chloris-biomass", "rescale": [1, 750000]}, + has_mosaic=False, + mosaic_preview_zoom=2, + mosaic_preview_coords=[30.0572, 80.1735], + requires_token=True, + minzoom=2, + ), "cop-dem-glo-30": DefaultRenderConfig( assets=["data"], render_params={"colormap_name": "terrain", "rescale": [-1000, 4000]}, diff --git a/pctiler/pctiler/colormaps/__init__.py b/pctiler/pctiler/colormaps/__init__.py index a0cb970..42d5d5d 100644 --- a/pctiler/pctiler/colormaps/__init__.py +++ b/pctiler/pctiler/colormaps/__init__.py @@ -6,6 +6,7 @@ from rio_tiler.colormap import cmap from rio_tiler.types import ColorMapType from titiler.core.dependencies import ColorMapParams +from .chloris import chloris_colormaps from .jrc import jrc_colormaps from .lulc import lulc_colormaps from .mtbs import mtbs_colormaps @@ -20,6 +21,7 @@ custom_colormaps: Dict[str, ColorMapType] = { **jrc_colormaps, **lulc_colormaps, **mtbs_colormaps, + **chloris_colormaps, } for k, v in custom_colormaps.items(): diff --git a/pctiler/pctiler/colormaps/chloris.py b/pctiler/pctiler/colormaps/chloris.py new file mode 100644 index 0000000..927b929 --- /dev/null +++ b/pctiler/pctiler/colormaps/chloris.py @@ -0,0 +1,32 @@ +from typing import Dict, cast + +import matplotlib +import numpy as np +from rio_tiler.types import ColorMapType, ColorTuple + + +def make_biomass_colormap() -> ColorMapType: + biomass = matplotlib.colors.LinearSegmentedColormap.from_list( + "chloris-biomass", + [ + "#c6c875", + "#77a865", + "#3d8757", + "#29583a", + "#2e3926", + "#050603", + ], + 256, + ) + ramp = np.linspace(0, 1, 256) + cmap_vals = biomass(ramp)[:, :] + cmap_uint8 = (cmap_vals * 255).astype("uint8") + colormap = { + idx: cast(ColorTuple, tuple(value)) for idx, value in enumerate(cmap_uint8) + } + return colormap + + +chloris_colormaps: Dict[str, ColorMapType] = { + "chloris-biomass": make_biomass_colormap(), +}