I want to add color, using RGB values stored in a CPT file, to a black and white Int16 GeoTIFF file using Python.

I tried to use SetColorEntry(), but when I add the ColorTable to the RasterBand, I get the following error:

ERROR 6: SetColorTable() only supported for Byte or UInt16 bands in TIFF format.

The GeoTIFF is a bathymetry where the values range from -5000 to 50. Using Byte or UInt16 would result in a lot of data loss

Can someone help me out and point me in the right direction?


You need to use gdal.GPI_RGB or gdal.GDT_UInt16 and not gdal.GDT_Int16.
That's the idea behind this error !

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.