Convert cpt file to svg file


Hello all
How can I convert cpt file to svg file

Cpt are just a list of numbers to be interpreted as colours.
SVG is a 2D picture…
Do you have an example of what you want to achieve?

SVG is also a format for cpt. Check this link

I don’t know how to convert the format. I would check on cptcity if exits or do it manually.

A quick web search turned up cptsvg which, according to the man page, “convert[s] GMT colour palette tables (cpt) to SVG gradients”


SVGs are written in XML code

That’s how… got it

Here there is online version

And what do we do with that SVG image other than display it?

Just to clarify, SVG has a colour gradient element, which looks like

<linearGradient id="Blues_03" gradientUnits="objectBoundingBox" spreadMethod="pad" x1="0%" x2="100%" y1="0%" y2="0%">
  <stop offset="0.00%" stop-color="rgb(222,235,247)" stop-opacity="1.0000"/>
  <stop offset="33.33%" stop-color="rgb(222,235,247)" stop-opacity="1.0000"/>
  <stop offset="33.33%" stop-color="rgb(158,202,225)" stop-opacity="1.0000"/>
  <stop offset="66.67%" stop-color="rgb(158,202,225)" stop-opacity="1.0000"/>
  <stop offset="66.67%" stop-color="rgb(49,130,189)" stop-opacity="1.0000"/>
  <stop offset="100.00%" stop-color="rgb(49,130,189)" stop-opacity="1.0000"/>

the cptsvg program converts cpt to that format, and that can be accessed from cptutils-online site as mentioned above.