12

I have a point shapefile which has for a few occasions multiple points with the same ID. Doesn't look nice with the normal label-display.

Is it possible in QGIS to only display one label then? I couldn't find a check/uncheck option... Perhaps it would be possible to retrieve labels via a SQL-query, with a GROUP BY id?

enter image description here

3 Answers 3

10

I assume that you have multiple features with the same ID and not real multipoint. If needed there is also a solution with real multipoint, let me know.

You can add an integer field to your shapefile that you populate with 1 if you want to display the label for this features and 0 for others.

Then in the renderer of the label use data-defined property for show or not labels.

enter image description here

EDIT :

Answer by @Kazuhito gave me an idea to go further.

You can also add two fields (x_lbl and y_lbl for example) and use them to get a total control on the placement of your label by using data-defined properties for label placement. Fill these fields with the coordinates where you need your label, you can then modify easily the place from the QGIS Interface. Look for this buttons:

enter image description here

1
  • 1
    I'm wondering if you have found any solution to labeling multipoint features because I'm stuck with this problem for real multipoint geometries now...
    – she_weeds
    Commented Feb 28, 2019 at 21:39
10

If a Virtual layer through Layer > Add Layer > Add/Edit Virtual Layer is an option:

SELECT id, st_pointonsurface(st_union(geometry))
FROM your_layer
GROUP BY id

will place a point around the center of each group.

I like the answer by @YoLecomte, which gives us more control in selecting where to put the label.

4

Another option is to use "Collect Geometries" under the Vector->Geometry Tools menu. Then choose the field to group them by. This will create multipart geometries with one table record and only one label will be generated for grouped features.

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.