I'm working with QGIS I have two layers:
- Layer 1: has the id and geom columns (multypolygon layer)
- Layer 2: has the id, gid and type columns (table layer).
The value gid of layer 2 is the foreign key and it is related with id of layer1, so for each id of layer 1 I have many gid of layer 2. I added the relation also in the Qgis project properties.
Now I need to do a rule-based symbology based on this relation 1:N. In layer 1 I want to show a different colour based on Type column of layer2. I suppose I have to do a rule-based for each Type but I don't know the expression to use.
I tried
relation_aggregate(relation:='gid_fk', aggregate:='array_agg'("Type", group_by:="Type", filter:="xxx"), expression:="Type")
but probably it is not the solution and there is a syntax error.
I try to do a more specific example: layer1 with id=0
is a geometry, layer2 gid0-Type1
is an economic activity and in gid0-Type2
is a touristic accomodation. So I have more information related to one geometry. I was wondering if i can assign a rule-based symbology using the relation_aggregate or if I should create a virtual layer with overlapped geometry, in that case I would obtain 1:1 and no problem of symbology.