Output data as SVG instead of PS

Dear all.
Thanks to the great GMT toolset we are able to create high quality maps as PDF files.
To enhance the usability of the Maps further, we want to switch to SVG format.
I tried converting PS and PDF files with pdf2svg and pstoedit, but the results were really bad.
Now I came up with the idea of developing a SVG exporter for GMT to use this instead of PSL. My questions are: is there already something like this out there? Does GMT have the architectural base (an Interface or something alike) to use something else than PSL as output?

Thanks again for the great GMT Software and this helpful community

Oliver Matz

Hi @MatzIT, I wish you all the luck with an SVG exporter, but I think your only option is to convert PDF to SVG. The big issue with the PS route is that postscript is a programming language and several things in GMT are implemented in postscript (estimating dimensions that depend on font sizes, clipping operations, etc…). The PDF version, however has already all of this computed and is available to conversion. Now, how to get good results out of this is another story, and one that I know nothing about.

Hi Joaquim. Thank you for your quick answer. I didn’t realize that PS has so much “power” in its language and that GMT uses these possibilities to such an extent. I took a deeper look in the generated PS and agree with your opinion that the SVG route, as direct export from GMT, would be a really strenuous path. So I will look for alternatives and report back here if I find a doable option.


Hi @MatzIT, the question of SVG output comes up every 5-6 years. My last discussion about this was in 2013 I think. As far as I can tell, there is no systematic embrace of SVG as a standard and Adobe Illustrator, browsers, InkScape all have serious and not always overlapping failures. It seemed like a good idea but the robustness is not there. I note that ghostscript used to have a driver that wrote SVG (and we supported it in psconvert) but they have now yanked it out as well.
I would be interested to hear if you find out that there is some progress on this somewhere. But as @Joaquim said, it should be done at the PDF->SVG level.

I think it is a good idea to support SVG format. Ref: https://www.educba.com/svg-vs-eps/ and https://www.amcharts.com/svg-maps/
But it depends on the choice of developers, because so far so good. GMT can plot high-quality figures for publication.