General description: I am using QGIS as quick visualization tool, where I make a "PostGIS" database layer and I see user generated events. Table structure as follows:

Id   |   time_of_event  | position         | heading  |
int  |   timestamp      | geometry(Point ) | smallint |

Specific problem: When I draw the position I draw it as point, I would like to draw it like so, if heading is = 0 or > 360, otherwise I would like to draw it as arrow.

I have read How to draw line pointing in compass bearing direction from point shapefile and Scaling vector field marker arrow based on attribute? but both of them are static.
And I couldn't figure out how to draw them based on a conditional, is this even possible?

P.S. I am using QGIS 3.2

Edit: so I made it display the proper direction: enter image description here

However how can I make a conditional, when heading is null, display red dot?

  • 1
    use Rule based classification; e.g. define a rule for heading = 0 OR heading = 360 and another for heading > 0 AND heading < 360 with respective symbols. rotation can then be applied separately.
    – geozelot
    Sep 18, 2018 at 9:42
  • @ThingumaBob very stupid question, however in which menu do I find this "rule based classification"? Sep 18, 2018 at 11:17
  • ,) I added all this as an answer.
    – geozelot
    Sep 18, 2018 at 17:18

1 Answer 1


Use the Rule-based classification for this.

Assuming dir is the field with the angle:

  • in the layers Symbology tab, choose Rule-based in the uppermost dropdown menu:

    ![enter image description here

    enter image description here

    • double-click the first entry to define the rule and name it if you like.
      then enter "dir" = 0 OR "dir" = 360 (or "dir" IN (0, 360)) in the Filter field (alternatively, you can open the Expression builder dialog to a GUI for function definitions):

      enter image description here

    • in the same menu, define your point symbol as you like

    • back in the rule overview, add a second rule (hit the green +) and define it:
      use either "dir" > 0 AND "dir" < 360 or select the Else bullet to simply select all features not in the other rules:

      enter image description here

    • this time, define your arrow and specify the dir field values in the Data defined override menu for Rotation:

      enter image description here

  • neatly done
  • Thank you , this is kindly simplified for "dummies", exactly what I needed. I marked it as the accepted answer! Sep 19, 2018 at 7:58
  • @thefolenangel glad it helped! ...I used to write those things more compact, and I hate screenshots and the hussle with them being right on spot. but then, there's no better way to ensure reproducibility. ...and since you asked...,)
    – geozelot
    Sep 19, 2018 at 8:03

Your Answer

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

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