Hi everyone,
Let’s say I want to plot some symbols on a map, each of them with their corresponding label nearby. But two of the symbols are so close to each other that their labels collide (see image).
Is there a way for GMT to recognize these situations and automatically apply a different offset to these labels so that they won’t collide?
Thanks for your help!
Short answer is no.
I know there’s somewhere in this forum a topic with the same issue and the solution was to use a script to compute the distances between labels.
Another approach (easier) is to post-process the images (pdf or postscript)
Right, we don’t.
I know that R has a solution for this (but an incomprehensible C code) but even Matlab (at least up until very recently) does not. I looked at this once and seems the existing solutions are based on algorithm that assign an electric charge to labels but also connect them with springs. The solution is the equilibrium of electrostatic repulsion and Hooke’s spring deformation. Interesting problem but had no time to pursue it.
Thank you for your answers!
I mostly do post-processing for labels but in this case we are trying to automatize the generation of maps in a website. I will explore the distance between labels approach.
If you have any breakthroughs, please share!
QGIS has a function to avoid overlapping labels that I have used before. It works well.