2021-05-11T09:33 PM
Hi Pete,
In most of our readers we use a helper method (see format_colortable and load_colormap defined in syntool_converter/utils/syntoolformat.py) that supports matplotlib and a few other colormaps to build the object that we assign to the colortable field of the band.
Note that using the helper method is not mandatory: as long as a gdal.Colortable instance (wherever it comes from) matching your colormap is assigned to the colortable field, the resulting GeoTIFF will use a palette based on your colormap to render unsigned byte values as RGB.
If your colormap is really not supported (i.e. not a matplotlib colormap nor one of the other colormaps supported by Syntool), I think you should make a copy of the format_colortable method in your reader and implement a custom load_colormap method which builds and returns a matplotlib.colors.LinearSegmentedColormap for your colormap.
Cheers,
Sylvain
In most of our readers we use a helper method (see format_colortable and load_colormap defined in syntool_converter/utils/syntoolformat.py) that supports matplotlib and a few other colormaps to build the object that we assign to the colortable field of the band.
Note that using the helper method is not mandatory: as long as a gdal.Colortable instance (wherever it comes from) matching your colormap is assigned to the colortable field, the resulting GeoTIFF will use a palette based on your colormap to render unsigned byte values as RGB.
If your colormap is really not supported (i.e. not a matplotlib colormap nor one of the other colormaps supported by Syntool), I think you should make a copy of the format_colortable method in your reader and implement a custom load_colormap method which builds and returns a matplotlib.colors.LinearSegmentedColormap for your colormap.
Cheers,
Sylvain