This topic goes into making polygons based on point locations; Using QGIS Geometry Generator to get rectangle from point? Is there a way to apply a rotation to the geometry generated? I have a field that contains a 0-360 degree rotation value and would like to rotate my built geometries based on that value.

  • I think I asked my question wrong, sorry. I am looking to use the geometry generator in the styles dialog to build polygons from points with attributes for "length" and "width". I can build the polygons using the answer provided in the link but my point file has an additional field called "rotation". I would like to rotate the polygons generated based on the rotation field in the attributes for each feature.
    – MrKingsley
    Commented Aug 30, 2017 at 18:05

2 Answers 2


I would suggest using shapely which is provided as a python package. You would interested in the rotate function:

shapely.affinity.rotate(geom, angle, origin='center', use_radians=False)¶
Returns a rotated geometry on a 2D plane.  
The angle of rotation can be specified in either degrees (default) or   radians by setting use_radians=True. Positive angles are counter-clockwise and   negative are clockwise rotations.  
The point of origin can be a keyword ‘center’ for the bounding box center   (default), ‘centroid’ for the geometry’s centroid, a Point object or a   coordinate tuple (x0, y0).  
The affine transformation matrix for 2D rotation is:  
/ cos(r) -sin(r) xoff | sin(r) cos(r) yoff | 0 0 1 /
where the offsets are calculated from the origin Point(x0, y0)

This thread provides an example possible setup

Also, this is a C++ solution you can check out as well.


enter image description here

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.