Using GMT CPT file with gdal raster color
Sean King via gdal-dev <[email protected]> Sun, 17 May 2026 13:24:13 -0700
| Newsgroups | gmane.comp.gis.gdal.devel |
|---|---|
| Message-ID | <CAAaFaTknK4dWH8ncGt1DHSrxMVHm=5OAgWoO=vHgM=vm=ng5KQ@mail.gmail.com> |
--00000000000049808a0652093af3 Content-Type: multipart/alternative; boundary="0000000000004980890652093af1" --0000000000004980890652093af1 Content-Type: text/plain; charset="UTF-8" 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 --0000000000004980890652093af1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi folks,<div><br></div><div>I'm using GMT version 6.6= .0 and GDAL version 3.12.4. I have several=C2=A0CPT files that I generated = in GMT using the makecpt command, such as:=C2=A0</div><div><br></div><div><= b><i>gmt makecpt -T-120/120/10 -I -Crainbow -Z -Fr</i></b></div><div><br></= div><div>which generates the attached file.=C2=A0Then, I am trying to apply= that color palette to a TIFF file using 'gdal raster color'. The <= a href=3D"https://gdal.org/en/stable/programs/gdaldem.html">documentation</= a> states that=C2=A0</div><div><br></div><div><b><i>GMT .cpt palette files = are also supported (COLOR_MODEL =3D RGB only).</i></b></div><div><br></div>= <div>however, I continually get the error of=C2=A0</div><div><br></div><div= ><b><i>ERROR 1: No color association found in test.cpt</i></b></div><div><b= ><i><br></i></b></div><div>When I dug into the GDAL source code for the GMT= CPT parser <a href=3D"https://github.com/OSGeo/gdal/blob/b3f839f2515b023e4= a7cf099b7ce1626ccb24eac/gcore/gdalcolortable.cpp#L744">here</a>, it really = does not seem to match up with=C2=A0the current implementation of GMT CPT f= iles, even though the GDAL feature was added in the latest release. For ins= tance, it uses space, comma, tab, and colon as delimiters, but no matter wh= at flags I use for my GMT CPT generation, I get a backslash as the delimite= r, as seen in the attached file. There are other inconsistencies as well.</= div><div><br></div><div>Am I missing something? I'm somewhat new to GDA= L and GMT, so I'd appreciate any advice. Also, if this feature really t= o read GMT CPT files is not adequate, is there a better way to approach thi= s? I essentially want to colorize a .grd file using gdal, so that I can the= n 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 wo= ndering if there is a more 'official' way to do this.</div><div><br= ></div><div>Thanks!</div><div>Sean</div></div> --0000000000004980890652093af1-- --00000000000049808a0652093af3 Content-Type: application/octet-stream; name="test.cpt" Content-Disposition: attachment; filename="test.cpt" Content-Transfer-Encoding: base64 Content-ID: <f_mpa7ox1p0> X-Attachment-Id: f_mpa7ox1p0 LTEyMAkyNTUvMC8wCS0xMTAJMjU1LzUzLjEyNS8wCUwKLTExMAkyNTUvNTMuMTI1LzAJLTEwMAky NTUvMTA2LjI1LzAJTAotMTAwCTI1NS8xMDYuMjUvMAktOTAJMjU1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MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ gdal-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/gdal-dev --00000000000049808a0652093af3--