19

With a lot of help from gis.stackexchange.com I've created leader lines for point symbols. The lines are based on a geometry generator symbology:

Shortening line geometry using expression dialog in QGIS?

enter image description here

Now, I want to implement leader lines for moved labels. It's very importent to me, that the lines start at the center of the labels and end at the point coordinates (or vice versa).

-- Geometry generator:
make_line(
    make_point(label_x, label_y),
    $geometry)

Once again, the lines are covered by the labels:

enter image description here

enter image description here

Is there a way to address the label boxes and shorten the leader lines? I suppose this is quite a tricky question :/

2

2 Answers 2

12

Firstly, this is a really neat solution! I solved this using a database view (a bit of overkill, but it worked).

My suggestion is to use a background and fill on the label.

Or, looking here, you may be able to chain together a buffer and clip type solution.

difference(make_line(make_point( "x" ,  "y" ), $geometry), buffer(make_point( "x" ,  "y" ),1))

I just tested the above, and it works (I have different fields than you, but it proves the point). The use of the geometry generator is really flexible, so you could have the buffer distance a field too, dependent on symbology perhaps?

I'm not sure what's happening with point 'three', but I guess the anchor point is off to the left a bit.

disjoint label leader lines

3
  • I've to do some tests in the next few days, but I'm afraid that a background will not work for complex projects without covering some layers. Commented Mar 23, 2017 at 18:18
  • Did you see the other part of my answer? I found something that will clip the leader lines for you @eclipsed_by_the_moon.
    – Alex Leith
    Commented Mar 23, 2017 at 21:37
  • Clipping leader lines for fixed size symbols works fine, but labels are an issue. I'll try to calculate the buffer distance dynamically, as soon as I find some time. Commented Mar 24, 2017 at 15:53
4

I currently work on a fork of easy custom labeling plugin, to enable automatic creation of label and linked header line.

Have a look at : EasycustomLabaling

Download it, unzip it, and paste the 'EasyCustomLabeling' repertory in the the repertory of your QGIS plugin repertory. Reload QGIS.

3
  • Your plugin is really useful, but I would prefer geometry generator created lines that start at the center of the labels. Commented Apr 2, 2017 at 20:11
  • I understand. For information, this can be set in the fields of the source layer when using this plugin (fields LblAlignV and LblAlignH) - Regards
    – patricev
    Commented Apr 3, 2017 at 16:10
  • Thx for the info, I'll test this at weekend. Commented Apr 6, 2017 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.