6

I have been given the big task of representing a lot of data in one symbol. The plan is to represent 5 categories of data in one symbol.

I hope to do this by changing factors such as:

  • Fill colour
  • Border colour
  • Shape
  • Orientation
  • Size

I planned on having:

  • Severity - changing border colour:
    - Serious - red
    - Slight - yellow
  • Road surface conditions - changing shape:
    - Dry - triangle
    - Wet - square
  • Light conditions - changing size:
    - Dark - small (4 points for example)
    - Light - large (8 points maybe)
  • Weather conditions - changing orientation:
    - Fine - vertical
    - Raining - 45 degrees clockwise
  • Casualty mode of transport - changing fill colour:
    - Pedal cycle - purple
    - Pedestrian - green
    - Moped - cyan
    - Car - black
    - Bus - white

Is there any way of doing this without typing out 80 separate statements and changing each variable individually?

1
  • 2
    expressions are your friend
    – Ian Turton
    Mar 17, 2023 at 17:33

2 Answers 2

11

Using "Data defined override > Edit...", use the following expressions. (Edit field names)

enter image description here

For "Size":

CASE
  WHEN "Light"='Dark' THEN 4
  WHEN "Light"='Light' THEN 8
END

For "Fill color":

CASE
  WHEN "Casualty mode"='Pedal cycle' THEN 'purple'
  WHEN "Casualty mode"='Pedestrian' THEN 'green'
  WHEN "Casualty mode"='Moped' THEN 'cyan'
  WHEN "Casualty mode"='Car' THEN 'black'
  WHEN "Casualty mode"='Bus' THEN 'white'
END

For "Stroke color":

CASE
  WHEN "Severity"='Serious' THEN 'red'
  WHEN "Severity"='Slight' THEN 'yellow'
END

For "Rotation":

CASE
  WHEN "Weather"='Fine' THEN 0
  WHEN "Weather"='Raining' THEN 45
END

For "Shape":

CASE
  WHEN "Road surface"='Dry' THEN 'triangle'
  WHEN "Road surface"='Wet' THEN 'square'
END

Toy data and result:

enter image description here

3
  • Thank you so much for your help, I would never have got here on my own. The only problem I'm having is that I cannot seem to work out how to write the expression to change the shape. It doesn't have the same menu as the other features. Is there a trick to it? Mar 20, 2023 at 11:02
  • I've added a screenshot. What is the geometry type of the layer? polygon, line or point? The answer is for a point layer. Mar 20, 2023 at 11:20
  • And please remember that you need to change field names in expressions. I made it up for testing. Mar 20, 2023 at 11:26
3

All of your visual variables can be driven by expressions so you need to write 5 expressions with a number of cases for each variable.

For Example

case 
when  "conditions"  =  'wet' then 'square'
when  "conditions"  =  'dry' then 'triangle'
end

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.