I have a dataset that includes populations and subpopulations, so for each main population there may be several subpopulations. I have organised this in the table so that a population has the same code, and then in a separate column if it is a subpopulation then it has been given a letter 'a, b, c, d, etc' with the 'main' populations all having a blank cell under the subpopulation column.

For example:

enter image description here

In the above dataset, row no. 1 is the main population and has the accompanying subpop code column is blank/null and it has 8 subpopulations (a-h).

Is there some way, some expression I can use, under symbology to give all 'main populations' i.e. those with a NULL subpopulation code a particular symbol and all those populations where the subpopulation code column is NOT NULL another symbol?

I have many different species, so ideally I would like the main population for each species to be a different colour, but a larger point dot. And all the subpopulations for each species to have the same colour as the main population but be a smaller dot.

enter image description here

So essentially showing something that looks like the above map. I just used filters to get this result and created a duplicate layer so that I could set the symbology differently for each.

I am still learning QGIS and know the basics, but just starting to get my head around using more advanced features.

2 Answers 2


Mapping plant populations- that's right up my alley!

You can use rule based symbology and rule based labeling to replicate your example above.

Just use the simple IS NULL or IS NOT NULL filter.

Below is a simple example I set up on a test point layer (Mine happens to be Acacia tolmerensis), I just added a couple of columns to my attribute table to look similar to yours.

In the layer properties dialog under the symbology tab select Rule-based. Double click the row to edit the filter for the first rule. Create one rule for each filter you want and set your desired symbology (marker size, colour etc.). Use the green plus sign to add more rules. You can add as many additional rules as you like.

Symbology dialog:

enter image description here

Then do the same for with labeling rules.

You can double click on any row in either dialog to edit a rule's filter, symbology or label.

Labeling dialog:

enter image description here


enter image description here


A good answer based on rule-based symbology has been given. To complement it, I find I often want symbology that differs in subtle ways based on rules, like same symbol but different colour, or an extra circle around (using your example) sub population is not null.

In such a case, using the rule based renderer involves duplicate work since the symbols need to be set up very similarly. And it can be challenging to maintain if you want to make minor tweaks that need to be propagated to each branch of the rule tree, for instance changing the symbol size or adding a glow or shadow.

In such cases, continuing to use the single symbol renderer with data-defined overrides can be very helpful. Or an additional symbol layer that gets rendered only if a condition is satisfied.

Data-defined override is activated in most symbol settings with an icon to the right that looks like a tiny drop down menu. You can specify various conditions, including by expression. Example (in your instance) for larger symbol size when subpopulation is null:

if("Subpopulation" is Null,5,3)

Symbol layers are added with the + icon to the right of the symbol layer tree. You could add an additional symbol layer to e.g. draw an outer circle around a dot drawn for all features. To do that, create the additional later, and down below in its properties choose the data-defined override icon beside Enable symbol layer and add as condition something like "Subpopulation" is null. You can even have 2 layers, one that turns on under a certain condition, the other in the negation of that condition. But then you are getting towards the ideal use case of the Rule-based renderer.

Finally, if in your data-driven override expression you have multiple choices (>2), it is probably easier to use a CASE WHEN construction rather than the if(...,...,...) function or if statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.