2

In QGIS 3, I have a polygon layer with numerous styles of which one is a centroid fill rendered using an SVG marker. I would like to override the path field, so that the marker would show up only for polygons larger that x square meters.

CASE WHEN area($geometry) > 1500000
THEN 'C:/OSGEO4~1/apps/qgis/svg/gpsicons/tree.svg'
ELSE ' '
END

Yet, I am not sure what to type after ELSE, since by leaving a single blank space, I end up with question marks (unknown/undefined symbol).

Can this be done or is there a better solution?

1 Answer 1

6

It can be done and there is a better solution..

Using your approach, you can keep the path but affect the size of the symbol, with a size of 0 to hide it.

if (area($geometry) > 1500000,4,0)

While it does work, it is not clear at all and someone will eventually spend hours wondering why some features are not displayed, or why all of them are displayed after changing the layer's projection.

The clean method would be to use rule-based styling and to include a style that is only applied to the large polygons. Note that it is the opposite approach: you don't prevent styling of small polygon, you now permit styling of large ones.

enter image description here

enter image description here

1
  • Since I didn't want having a rule-based style in the first place, the if solution was the best in my particular case. Thank you for your help.
    – Cezar B
    Commented Mar 9, 2018 at 23:56

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.