I have a problem with a polygon layer.

Its an equipment and services layer... I want to aggregate different types of services in similar legend, like this:

enter image description here

For example, these four :

"Ensino Especial" "Ensino Básico" "Creche/Jardim de Infância/ATL" "Ensino Secundário"

I want to label all of them as "Equipamento de Educação" (Education Equipment).

Do I have to use "Ruled-Based"? Do I write the RULE in every row?

By-hand, what I get is this:

enter image description here

Duplicated entries... When I switch to print composer...I get at least four "Equipamentos de Educação" :/

But I want one label for "Equipamentos de Educação" that conjugates all of these: "Creche/Jardim de Infância/ATL"; "Ensino Especial"; "Ensino Básico"; "Ensino Secundário"..."


There are several ways to achieve this purpose. You can always create rules for labelling, as you suggested, but you could try adding a new column to your file with the label for each desired class.

This way is beneficial compared to creating rules, because the rules will be associated with your project file, and should you move your data elsewhere, you'd have to recreate them.

One way to create this column would be via the "Field Calculator" in QGIS. You could try something like:

CASE WHEN "ACTIVIDADE" = 'Ensino Especial' OR 
"ACTIVIDADE" = 'Creche/Jardim de Infância/ATL' OR
"ACTIVIDADE" = 'Ensino Especial' OR ... --Adapt this to your needs.
THEN 'Equipamento de Educação'

I would recommend checking out the QGIS documentation for the Field Calculator available here. Try reading a bit about SQL Conditional Statements as well.

| improve this answer | |
  • Thank you! I would like to learn how to work with the rule-based categorization, but this way (creating new column) seems the easiest and efficient way to solve my problem! Another time :) – M_M Apr 11 '17 at 16:45
  • @M_M, the power of QGIS! – mgri Apr 12 '17 at 6:34

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.