I work with QGIS 2.18. I have a polygon shapefile with two atrributes: id (unique for each polygon) and type.

I visualize the shapefile using the "type" attribute, but I would like to add a nested rule or category using the "id". When I try to do that, for each type, all the available ids are added when, what I want is to add only the ids that correspond to the type I am modifying.

For example, if I have

"id" "type"   
  0  forest
  1  road
  2  road
  3  river
  4  forest
  5  building
  6  river

I would like to have:

  • One category for 'forest' with the nested values of "id" 0 and 4
  • One category for 'road' with the nested values of "id" 1 and 2
  • One category for 'river' with the nested values of "id" 3 and 6
  • One category for 'building' with the nested values of "id" 5

For 6 features it is simple, but I have 200 hundreds of them.

The goal is to keep the visualization by type and to be able to hide/show the features that I am interested in.

I know I can use the filter option, but when the filter is active I loose the ability to edit the file. I could also split the file using the "type attribute" but I would like to avoid doing that and to keep everything in one file.

Is there a way to do that?


Go to layer > properties > style

Choose Categorized as styling-preference

enter image description here

Now set column to 'type' and click Classify.

enter image description here

Every single category will show up.

If you just want to visualise one category-type at a time, you can uncheck the others in the legend of the TOC.

  • I think with this approach there will be a border (of course based on visualization techniques) between features of the same class that probably does not give a nice view. I assume the "Dissolve" algorithm might be applied first and then "Categorized"-style – Taras Apr 8 '19 at 9:14
  • @Taras, if it is needed, you can disable the border style in the styling manager... – PieterB Apr 8 '19 at 9:32
  • @PieterB. Thank you but I don't see how your answer answers to the question. You are describing a categorized visualization which is very straightforward. I am asking for a nested visualization where for each category I can have listed all the corresponding features and where I can hide/show each feature individually without losing my type visualization. – geotyr Apr 8 '19 at 11:32
  • do you just want to viualise one category-type at a time? You can uncheck the others in the TOC – PieterB Apr 8 '19 at 11:41
  • @PieterB I would like to be able to uncheck each feature separately without losing the visualization by category, that is why I am asking for nested options – geotyr Apr 10 '19 at 16:42

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.