5

I've followed this tutorial to be able to move label positions and draw lines to connect them to the label dots, but I'd like to restrict the line drawing to 45˚ angles.

Is there a way to do that? I see this in the changelog for QGIS 3.8 but can't figure out how to implement.

map with messy labels

  • 1
    What do you exactly mean by restricting the line to 45˚? Is it drawing labels only in a range from 0˚ to 45˚, or bigger than 45˚, or just 45˚ for all lines? – Taras Sep 17 at 5:42
  • 45 for all lines! – larrybuch Sep 18 at 2:12
  • I think @kazuhito has answered your question but just as a FYI QGIS 3.10 (meant to come out in the next few days...) will have inbuilt label leader options - I presume there will be an option that snaps to certain angles... twitter.com/northroadgeo/status/1160421820987613184 – she_weeds Sep 21 at 2:58
2

If you are trying to move the label and line by a fixed distance (a 50m-case below);

enter image description here

Then the Geometry Generator expression for the Label would be:

project($geometry, 50, radians(45))

enter image description here

And the associated leader Line would be:

make_line($geometry, project($geometry, 50, radians(45)))

enter image description here

Perhaps you want more control over the offset distance, then prepare a field (such as "dist") and change project($geometry, 50, radians(45)) part to project($geometry, "dist", radians(45)) .

  • thank you kazuhito! – larrybuch Sep 22 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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