Quick overview how to create new geometries using QGIS expressions with either Geometry generator
or Geometry by expression
:
Geometry generator: Open Layer Styling panel / add additional symbol layer (green +
) / Symbol layer type
: Geometry generator
/ set appropriate Geometry type
(point/line/polygon) / add your expression
Geometry by expression: Menu Processing / Toolbox / Geometry by expression
/ choose input layer / set appropriate Output geometry type
/ add your expression
Overview Differences: Table Geometry generator
vs. Geometry by expression
- highlighted in green which option is better fit for the corresponding task:

In more details: You can use the same expressions in both ways, depending on what you use it for.
Geometry generator: This is useful for creating dynamic geometries on a layer for visualization purposes only. Disadvantage: They are symbologies, thus you can't use it for further geoprocessing.
Advantage: However, they are great because you can see in realtime how the geometries change when you change the expression. You can try this with a simple example: use buffer ($geometry, 1)
and add zeros to the number 1 to see the buffer successively increase with each digit you add. Like this, you can control the appearance of the geometry you create in a very intuitive way and learn how different settings affect the geometry.
How to do it:
- Open Layer Styling panel and add an additional symbol layer by hitting the green plus symbol:
+
.
- Than set the
Symbol layer type
to Geometry generator
.
- Select a
Geometry type
: it is the kind of geoemtry you want to create, not the one of the geometry the expression is based on. A simple example: if you want to create a buffer, always select Polygon / MultiPolygon
, irrespective if you buffer a point, line or polygon layer. If you create a centroid, however, always set Geometry type
to Point / MultiPoint
.
- Add the expression. You might use the epsilon (
ε
) button to open the powerful Expression string builder
: see details about it in the documentation
Screenshot: how to use Geometry generator
. Starting point is a line-layer (black line). Add a symbol layer in the layer styling panel and on this symbol layer create a buffer (transparent orange), here with the expression buffer ($geometry, 100)
. Change the shape of the black line or the buffer-distance from 100
to any other value to see how the orange buffer changes:

Geometry by expression: This is useful if you need the created geometries for further processing. It will create a new layer containing the generated geometries and will thus be permanent (if you save the layer). Once executed, you can't however adapt the settings any more (as in the more flexible case of geometry generator, where you can always change settings, however the geometries can not be used for further processing).
How to do it:
- Go to
Menu Processing / Toolbox / Geometry by expression
- Choose the input layer: the layer the expression is apllied to
- As
Output geometry type
, set the kind of geoemtry you want to create (see above for details)
- In the field
Geometry expression
, introduce the expression you want to use for generating geometries. You can use Expression string builder
(ε
): see details above.
Be aware that some functions available in geometry generator are not properly supported when using Geometry by expression
, e.g. the variable refering to the current layer @layer
or aggregate functions.
Screenshot: using Geometry by expression
, creating the centroid of the line layer. It will be generated as a new point layer:

Reference: