In QGIS (2.18), how do you show only one label per field of view in the map canvas for each visible category (that is displayed in the map view/canvas at any given scale/focus) of a multi-feature polygon layer that has been styled with different colours and returns different labels based on fields in its attribute table?

I have a base layer with many polygons and detailed attributes for a QGIS project that I am loading on an Android device using the wonderful QField app.

My problem is that in each map view I have many coloured attributes representing different vegetation types that each show a label for almost every polygon. This clutters up the view considerably.

Result sought:
I only need one label per categorised polygon result (colour etc.) showing per map view, not a label for every polygon visible.

i.e. I need at least one label of every category of vegetation type polygon visible in each map view showing at all times, but I don't want to show two (or more) labels for say "rainforest" if there are 50 small polygons visible.

Or, if there are 5 polygons for "rainforest", 2 polygons for "woodland", and 1 polygon for "lagoon", at all times, I want only one of the polygon's (perhaps either the biggest, average or smallest) for each vegetation type showing.

Tried/doesn't work:
1/ Unfortunately I can not just dissolve the layer by attribute and then show all the visible layers as the shapefile is too big to have to load in its entirety every time.

2/ Can't simply suppress small polygon shape size labels as some very comparatively small polygons require labelling.

Hoping there is either a built in labelling function button I am missing that help's with this, or a formula I can embed in my current labelling formula to achieve this.

Perhaps there is a QGIS variable equal to "map view" ("canvas extent/view") that may assist?

Or a query to say "show only one label per attribute result visible in map canvas"?

  • 1
    Similar to using dissolve (unsure how much difference it will make in terms of file-size) but another method is to convert your polygon layer to a multipolygon layer using Vector > Geometry Tools > Singleparts to Multipart and select your category field as the Unique ID field. – Joseph Nov 21 '16 at 13:24
  • Thanks for the suggestion @Joseph. Unfortunately the vegetation type polygons have complex attribute tables associated with them (used for other purposes) which it seems would be lost if I converted to multipolygon dissolved on one category. – guestagain Nov 22 '16 at 10:38
  • 1
    You don't have to get rid of the original polygon layer to implement Joseph's solution. Keep the original layer in the map, but turn off the labels. Create a multipolygon layer as Josephs suggested. Turn on labels for the new layer, and set fill style to No Brush and border style to No Pen. – csk Nov 22 '16 at 17:21
  • That is true @csk (and have done similar for other smaller files), however unfortunately my EVC (vegetation type) layer is massive, and I am making the maps for the QField Android app so trying to prepare my project as slim as possible. Also the EVC layer uses multiple values for its label that would be lost via either dissolve/multipolygon option (i.e. the EVC vegetation label is the primary label, but, depending on the bio-region it falls within, it gets another label for conservation status, and it seems the multipolygon solution only works on one category/attribute value). – guestagain Nov 23 '16 at 5:58
  • Perhaps could dissolve by two or three categories, then assign an ID, and then convert to multipolygon. But was trying to avoid too many steps and solve in labelling engine as this will become quite an involved task every time the dataset is updated. – guestagain Nov 23 '16 at 5:58

Your Answer

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

Browse other questions tagged or ask your own question.