Skip to content

Commit

Permalink
Add io-bii colormap (#159) (#168)
Browse files Browse the repository at this point in the history
* feat: io-bii colormap

* fix: apply format

Co-authored-by: Preston Hartzell <[email protected]>
  • Loading branch information
lossyrob and pjhartzell authored Apr 10, 2023
1 parent ca2fec8 commit df440ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pctiler/pctiler/colormaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from .alos_palsar_mosaic import alos_palsar_mosaic_colormaps
from .chloris import chloris_colormaps
from .io_bii import io_bii_colormaps
from .jrc import jrc_colormaps
from .lidarusgs import lidar_colormaps
from .lulc import lulc_colormaps
Expand All @@ -25,6 +26,7 @@
################################################################################
registered_cmaps = cmap
custom_colormaps: Dict[str, ColorMapType] = {
**io_bii_colormaps,
**jrc_colormaps,
**lulc_colormaps,
**modis_colormaps,
Expand Down
32 changes: 32 additions & 0 deletions pctiler/pctiler/colormaps/io_bii.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import Dict, cast

import matplotlib
import numpy as np
from rio_tiler.types import ColorMapType, ColorTuple


def make_io_bii_colormap() -> ColorMapType:
io_bii = matplotlib.colors.LinearSegmentedColormap.from_list(
"io_bii",
[
(0.0, "#72736c"),
(0.2, "#ccd3c5"),
(0.4, "#cceaa2"),
(0.6, "#69be72"),
(0.8, "#309d53"),
(1.0, "#006a37"),
],
256,
)
ramp = np.linspace(0, 1, 256)
cmap_vals = io_bii(ramp)[:, :]
cmap_uint8 = (cmap_vals * 255).astype("uint8")
colormap = {
idx: cast(ColorTuple, tuple(value)) for idx, value in enumerate(cmap_uint8)
}
return colormap


io_bii_colormaps: Dict[str, ColorMapType] = {
"io-bii": make_io_bii_colormap(),
}

0 comments on commit df440ee

Please sign in to comment.