I intent to expand a layer's symbology by a geometry generator using the following expression:

case when attribute > 2 then 
buffer($geometry, attribute)

However it doesn't work (also when incorporating a else-clause). When using this expression with 'Geometry by Expression' it returns invalid geometries. I want the geometry generator to draw a buffer only on certain features by using a conditional expression - how to do this? Is this possible at all?

  • 1
    Why not if("split">2, buffer($geometry,"split"), $geometry) ?
    – Taras
    May 9 at 6:11
  • Did you check if your initial features do not contain geoemtry/topology errors? Did you try simply using buffer($geometry, 1) to see if that works?
    – Babel
    May 9 at 7:29
  • You are missing double quotes around you attribute as well. Should be "attribute". May 11 at 12:37
  • Double quotes are not mandatory, works also without
    – Babel
    May 11 at 15:45

1 Answer 1


You code works fine for me.

I have:

case when  "split"  > 2 then 
buffer($geometry, "split")

With split being the name of the column with numeric values, and it works fine.

Possible other issues:

Your attribute field is not numeric, so if it's text you would have to wrap it in a to_real function: to_real( "split" )

Also make sure the resulting geometry type is Polygon / MultiPolygon.

  • Strange. My field type is numeric. Layer geometry is line, polygon is selected as generator type, hence no else-clause. I don't know what else could have been overlooked...
    – maxwhere
    May 8 at 23:53
  • 2
    Can you share your data, or a portion?
    – Stu Smith
    May 9 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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