Monday 19 August 2019

qgis - Label callout lines to the closest point on the label


I am trying to improve callout lines on maps I'm making. I'm currently using the method in this link to make my callout lines. That works fine, bu I'd like the lines to always go to the closest point of the label like this:


enter image description hereenter image description here


enter image description hereenter image description here


I think it would work if I used code down the line of this in the expression editor for the geometry generator.


make_line(
make_point($x, $y),
make_point((CASE

WHEN "auxiliary_storage_labeling_positionx" > $x
THEN "auxiliary_storage_labeling_positionx"
WHEN ("auxiliary_storage_labeling_positionx" + "labelwidth") > $x
AND ("auxiliary_storage_labeling_positionx") < $x
THEN ("auxiliary_storage_labeling_positionx" + "labelwidth")
ELSE $x
END )
,(CASE
WHEN "auxiliary_storage_labeling_positiony" < $y
THEN "auxiliary_storage_labeling_positiony"

WHEN ("auxiliary_storage_labeling_positiony" + "labelHeight") < $y
AND ("auxiliary_storage_labeling_positiony") > $y
THEN ("auxiliary_storage_labeling_positiony" + "labelHeight")
ELSE $y
END )
)
)

I'm not sure if I have all the < and > correct but that's beside the point. The issue with that is that I can't seem to figure out how to get the width and the height of the label.


I am not very good with the expression editor, and have never done anything with the function editor.





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...