11

Is it somehow possible in QGIS to connect labels and points with a line/arrow or something? In my map it is not clear which label goes with its point. I can't bring it closer because there are many more points to come.enter image description here

  • xof solution works for me. But I would like to know if it possible to have a short legend in my shape listing... not like this exemple below, with already a short label... ![My test](i.stack.imgur.com/8VWoN.png) Thank you ! – MathieuG Dec 28 '18 at 4:28
7
  • First, create labeling fields for X and Y position of your labels in your point table.

  • Activate the X and Y positionning in the properties of your layer.

override

  • Create a new "Generator expression" style in your point style, set it to line type, then use the following formulae :

    make_line(make_point($x,$y),make_point( "LABEL_X" , "LABEL_Y" ))

As an enhancement, you can use various fields (or use a plugin to create them all) to control where the align point will be. You could have the use of a rotation field and a vertical and horizontal alignement field.

styling

The line will move accordingly to your label position, as its arrival point is related to the label positon field.

5

You could try downloading and installing the EasyCustomLabeling plugin from Plugins > Manage and Install Plugins, this creates a duplicated memory layer of your selected vector layer and contains the same attributes.

(Note that you will also need to download and install the Memory Layer Saver plugin to save the memory layer correctly, this is described in the plugin description).

Once your label layer is created, you can play with the label placement and style of that layer to try and get what you're looking for:

Plugin

Label layer settings

Label layer

Hope this helps!

  • thank you @ Joseph. Is it correct that I can only chose one attribute with this plugin? (btw: should this also be a new question?) – kevkev Jun 3 '15 at 14:11
  • Nah! Not if it's a simple yes/no question =). But you are correct, only one attribute per layer, so you can make multiple label layers if you wish. – Joseph Jun 3 '15 at 14:15
  • Actually it is possible. After creating the label layer it's possible to change the attributes there :D – kevkev Jun 4 '15 at 7:13
  • @KevinSuhr - Brilliant! Thanks, I learnt something =) – Joseph Jun 4 '15 at 9:10
  • 1
    From @underdark 's post; A common use case is the wish to show multiple attribute values in a feature’s label. Using Field Calculator, you can combine them into multi-line labels. All you need is to combine the fields with the || operator and add ‘\n’ (newline) wherever there should be a line break: Field1 || '\n' || Field2 – Lee Jun 4 '15 at 18:03
4

Concerning the method by gisinside: the first step of manually adding x/y attributes for labels can be omitted; (maybe since QGIS3?) there's an auxiliary variable for label-positionings already present. The variables ar called accordingly: "auxiliary_storage_labeling_positionx" and "auxiliary_storage_labeling_positiony".

So in Step Nr. 2 you can use this expression to draw lines:

make_line(make_point($x,$y),make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony"))

Note however, that the auxiliary variables only get a value assigned, if you touch/move the labels with the move-label-tool. Therefore, you only see lines for labels that have been manually moved around.

2

If you are using PostGIS for your spatial data, this post https://sigsemgrilhetas.wordpress.com/2015/01/12/etiquetas-com-guias-em-qgis-e-postgis-labels-leading-lines-with-qgis-and-postgis/ by Alexandre Neto explains how leading lines can be added to the points in your database.

Its a well written tutorial worth reading, it also has a movie in the post that shows how it works.

Hope this helps.

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.