From a point geometry layer to which apply a Geometry Generator expression to creates a new geometry, my goal is to translate this expression rotating 180 degrees, and taking as reference the opposite side of a rectangle polygon layer.

  • 2
    translate(rotate($geometry, 180), [something with the centroid and x(@map_extent_center)]))? Feb 27 at 14:41
  • 1
    translate takes 3 parameters, a geometry, a dx and a dy (delta x, delta y). In your failed solution, you are passing make_line as dx.
    – Matt
    Feb 27 at 19:37
  • 1
    rotate($geometry, 180, center:=make_point(0,0))? I don't understand what you mean as "reference" for the 0, 0 coordinate on your left side and what you mean by "the limits of a rectangle polygon". Feb 27 at 19:38
  • 2
    What rectangle polygon though? Is it a fixed thing with fixed coordinates? Do you want the expression to look at its geometry? What is its relationship to the geometry you want to use the expression on? Feb 27 at 20:08
  • 1
    I answer your questions: The rectangular polygon is a layer with fixed coordinates with the extend -3.165,-9.939 : 36.678,10.0965. I think it is necessary for the point layer to look at the geometry of the polygon layer. After rotating, the point layer should be moved to the exact opposite side of the polygon. The relationship of the point layer to the polygon layer is that for each point the distance to the 0.0,0.0 coordinate is calculated. The opposite coordinate is 33.00, 0.0 Feb 27 at 20:26

2 Answers 2


If you're looking to rotate generic geometries, and not just points, then the rotate function should work. You just need to specify the right centre point - which is the centroid of the rectangle. It assumes you have a polygon layer called Rectangle with a single rectangle feature.

rotate(@geometry, 180, centroid(aggregate('Rectangle', 'array_agg', @geometry)[0]))

enter image description here

You should be able to replace the first @geometry with any arbitrary expression that creates a geometry - for example, make_line(make_point(0.0,0.0),$geometry).

I haven't done this as I don't have the same data set as you, but there's no reason that it shouldn't work.


If you're just to rotate your point within a polygon layer that has a single rectangle, you can use something like the following:


It relies on the fact that a rotation within a rectangle is just projecting the point from the centroid, the same distance and same angle again.

enter image description here

  • I have tried your solution, and it does the expected job, and it's almost what I'm looking for. However, I add in my question some remarks. In short, I would like your solution works with any expression no matter how complex it is Feb 28 at 7:30
  • 3
    @IngridIngravida, you should be able to replace @geometry in the distance and azimuth functions (lines 2 and 3) with any expression that creates a geometry.
    – Matt
    Feb 28 at 10:11
  • @Matt, thanks a lot for this instruction. I have tried to implement it but when I get to the azimuth function there seems to be an incompatibility. I have documented this test in my question Feb 28 at 10:53

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.