I have a number of point features and created various font and simple markers for each point.

I now want to add background for the Font marker, so that it would be readable against the basemap background. I assume a way to do this would be to add a geometry generator (polygon) for the layer. Now, I have a trouble creating the output desired to produce the polygon.

I have tried using make_polygon, but I can't understand what arguments need to be to produce a polygon. Ideally I want to specify origin point ($geometry=original point layer location) and -x, x, -y, y extents. Maybe there is another way to accomplish this?

TL;DR: Need to create a polygon with defined size using geometry generator based on point layer.

1 Answer 1


The make_polygon() function expects a line as input. Use the make_line() function to create a line.

The make_line() function expects a series of points as input. Use the make_point() function to create points.

The make_point() function expects input in the format of x,y. Use the variables $x and $y to get the x and y coordinates of the current point feature.

To make a rectangular polygon

make_polygon( make_line( make_point($x+dx, $y+dy), make_point($x+dx, $y-dy), make_point($x-dx, $y-dy), make_point($x-dx, $y+dy) ) )

Substitute appropriate values for dx and dy. They represent the amount to change the x and y coordinates of the current point, respectively.

  • Use a fixed amount if you want the same size rectangle for each feature.
  • If you want a different size rectangle for each feature, add a field called dx and a field called dy. Put the field names into the expression as "dx" and "dy".

Documentation for functions in the Expression Builder is built-in. When you highlight a function in the middle panel of the Expression Builder, the description, syntax and examples will show up in the right panel. If this panel isn't visible, click and drag from the right side of the window to expose it. enter image description here

  • Where do you get all this info? I'm really interested in learning more about Expressions, but official literature is quite limited (does not specify all the details like expected input/output), and there isn't much other info online.
    – Ruslan
    Jul 18, 2018 at 22:33
  • 2
    I agree, the documentation of expressions is not all it could be. I figure them out by reading the function syntax and examples documentation in the expression builder window. Then it's a matter of trial and error. There are also a lot of good examples on stackexchange. Check out answers posted by @Kazuhito, and also some of my other answers.
    – csk
    Jul 19, 2018 at 17:16

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.