9

I am a fairly competent QGIS (3.14) user but really struggling with a particular labelling issue. I want to create attribute-based symbols/labels based on multiple attributes for a single point, but with different combinations based on attribute values.

My data is structured as follows: each geographic point is a row, and then I have a series of attributes (hiking, swimming, fishing) as boolean yes/no values. What I want is to create labels or symbols for each point, and custom labels/symbology based on the boolean values (so, if place A has fishing, show a fish; for place B with fishing and swimming, show a fish AND a swimmer icon).

This would like something like this:

image of goal map

but with variation in the "Hiker/Biker Camp" image (not my map - an example to share).

I've tried using rule-based symbology with manual offsets, but that leaves an ugly gap if a point has attribute A and C but not B.

Is there a simple way to do this in QGIS 3.14 or with plug-ins?

3 Answers 3

11

You are on the right track. You just need to take into consideration the symbols to the left when you set the offset for each symbols.

For my example I will have 3 columns hike, bike, swim. Make sure that each column it's filled either with a zero (false) or a one (true)

enter image description here

Create a rule-based symbology with one rule for activity. Since the columns is boolean, the filter for each rule can be just the name of the column.

enter image description here

Set an equal size for all symbols and remember it (6.2 in my example).

Don't use any offset for the first column/activity. For the second (bike), use the following expression in the data overwrite options:

array("hike" * 6.2, 0)

For the third(swim):

array(hike * symbol_size + bike * symbol_size,0)

And so on.

The result:

enter image description here

6

My not very elegant solution to the same problem was to create one point symbol with all icon (svg icon, one symbol layer by svg) then for each icon I used data defined size based on the relevant column (a 0 size to make the icon Invisible, or the appropriate display size to display the icon). Then to deal with empty gaps I use data defined offset for each icon but the first. ( So first icon has no offset ; the second has an offset of 0 if there is no first icon and an offset of one icon size if there is a first icon ; the third has no offset if there is no first and second icon, an offset of one icon size if there is a first OR a second icon and an offset of two icon size if there is a first AND a second icon). This could be easily achieved by using the sum of the previous column (assuming true is coded by 1 and false by 0) and an offset expression like:

CASE WHEN "sum of previous column"=0 THEN 0 ELSE "sum of previous column" * "one icon offset value"

6

The quicker way is to use Categorized values with SVG markers - there you can offset each value so it is a consistent representation. Your data sounds like it has many more values (ones or zeros) but you could concatenate them into one field.

Example (Illustrative), Here 3 points are created in QGIS 3.18.1 but the attribution is styling up the based on the number of values with an offset.

(it doesn't look good in the table of contents, but on the map it works)

enter image description here

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.