[gdal-dev] Using GMT CPT file with gdal raster color
Sean King
seankingus at gmail.com
Sun May 17 13:24:13 PDT 2026
Hi folks,
I'm using GMT version 6.6.0 and GDAL version 3.12.4. I have several CPT
files that I generated in GMT using the makecpt command, such as:
*gmt makecpt -T-120/120/10 -I -Crainbow -Z -Fr*
which generates the attached file. Then, I am trying to apply that color
palette to a TIFF file using 'gdal raster color'. The documentation
<https://gdal.org/en/stable/programs/gdaldem.html> states that
*GMT .cpt palette files are also supported (COLOR_MODEL = RGB only).*
however, I continually get the error of
*ERROR 1: No color association found in test.cpt*
When I dug into the GDAL source code for the GMT CPT parser here
<https://github.com/OSGeo/gdal/blob/b3f839f2515b023e4a7cf099b7ce1626ccb24eac/gcore/gdalcolortable.cpp#L744>,
it really does not seem to match up with the current implementation of GMT
CPT files, even though the GDAL feature was added in the latest release.
For instance, it uses space, comma, tab, and colon as delimiters, but no
matter what flags I use for my GMT CPT generation, I get a backslash as the
delimiter, as seen in the attached file. There are other inconsistencies as
well.
Am I missing something? I'm somewhat new to GDAL and GMT, so I'd appreciate
any advice. Also, if this feature really to read GMT CPT files is not
adequate, is there a better way to approach this? I essentially want to
colorize a .grd file using gdal, so that I can then generate map tiles with
it. I have the rest of the pipeline figured out, but I'm having issues with
the color mapping. I wrote my own converter from GMT CPT to GDAL color
file, but it's a bit buggy/hacky. I'm wondering if there is a more
'official' way to do this.
Thanks!
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20260517/16ed9e78/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpt
Type: application/octet-stream
Size: 849 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20260517/16ed9e78/attachment-0001.obj>
More information about the gdal-dev
mailing list