7

I am exploring the new Label engine of QGIS 2.12.2 and I found it a great improvement. However, I discover it is not yet up to ArcGIS "standard" when dealing with multipart polygons. As a workaround (unless I am missing some hidden property), is there a way, through an expression to be passed to the label engine, to label only the largest feature (in terms of area or perimeter) of a multipart polygon?

2

This should be the default behaviour anyway, unless you've ticked the 'Label every part of multi-part features' checkbox (under Rendering tab):

enter image description here

  • I am aware of the option but it seems it places the label at the average centroid from the centroids of all parts and sometime this leads to unwanted situations (like in my case). This is why I am looking for a method to only label the largest of the parts. – fabio2111 Jan 15 '16 at 10:04
  • Hmm... doesn't do that for me. What other label placement settings have you got active? Can you post a summary? – ndawson Jan 16 '16 at 1:25
  • So by default there supposed to be only one label per multipart feature over the part with largest area? If so then the only key option should be to set in Labels / Placement to Horizontal (slow). – Miro May 19 '16 at 0:31
1

I had the same problem - QGIS was placing labels on some of the multi-polygon features inside / over the smallest polygon, while I wanted it to be centered between the two.

Try this:

  1. Vector > Geoprocessing Tools > Convex Hull
  2. Select the layer you are interested in labeling. You can select individual features, or all features.
  3. Select "Create convex hulls based on input field", and "Add result to canvas"
  4. Join the new layer with the convex hulls with your source layer
  5. Make the convex hull layer transparent
  6. Apply labels to the convex hull layer

Additionally, you can edit the nodes on the convex hull layer's features to manually control where the label appears.

1

Update: QGIS should have this as default behavior (see my second answer). But if for some reason you want to make sure or need some variation (perimeter, smallest area or something else) this is the way to go:

  1. Have a unique multipolygon ID column (MID)
  2. Convert multiparts to singleparts (Vector / Geometry Tools)
  3. Create area column
  4. Use Group Stats plugin to calculate the maximum area per MID (maxarea)
  5. Save the result as CSV
  6. Join the result to singleparts through MID (Layer Properties / Joins)
  7. Select in singleparts where area = maxarea
  8. Two options here as final step:
    • Populate selection with new column (ShowLbl) with 1 and use it in Labels / Rendering / Show label
    • Save singleparts selection as new layer and label only these features over original layer without showing the polygons

Unfortunately I can't imagine anything easier at this moment. QGIS labeling tools are becoming way more powerful in last years but there is still lot to achieve.

0

Based on other answer here I did some tests and surprisingly for me find out that what you ask for should be default behavior of QGIS except of one small change:

enter image description here

In the Labels settings under Placement switch to Horizontal (slow). That should do the trick.

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.