TransWikia.com

How to stylize polygons sharing the same attributes to represent a common outline

Geographic Information Systems Asked on April 1, 2021

In QGIS 3.14.16, I want to outline multiple polygons which share same attribute value.

Styling the layer with the same attribute value bring the following result:
enter image description here

The style I wish to have is:
enter image description here

I could use the dissolve function to get the expected result. However, this is not a solution for me, as I need to modify frequently the attribute table.

Is there a way to configure such a style?

My final goal is to style polygons layer with:

  1. Outlined polygons in function of a field (as described above),
  2. Colored polygons in function of another field.

Graphically speaking, I want to jump from that style:
enter image description here

to this:
enter image description here
Polygons are colored with category according to field A. They are also outlined with category style according to field B.

EDIT

Here are examples of what I tried so far:

Example 1:
enter image description here

Example 2:
enter image description here

Example 3:
enter image description here

Example 4 (this last example is the best way I found to circumvent that issue, see comments below):
enter image description here

One Answer

I would suggest using a Virtual Layer in conjunction with st_union().

Given a layer of polygons s with attribute r, click New Virtual Layer. On the dialog that appears, click Import to bring in the layer s.

Under Query, enter the following query:

  SELECT r,
         st_union(geometry)
    FROM s
GROUP BY r

The result will appear as a separate layer in the table of contents, but being linked to the same data source, will update as edits are made to the polygons layer. This new virtual layer can be styled separately, such as with a categorized simple outline.

In the image below, a series of squares are symbolized by one attribute, and a virtual layer as described above is overlayed.

grid with virtual layer

When the r attribute is edited for a selection of features, the virtual layer updates as well.

grid with virtual layer, with edits

Correct answer by JoshC on April 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP