I do not know how to rotate a geometry using pyqgis.
Is there any sample/example code available to show me how?
I do not know how to rotate a geometry using pyqgis.
Is there any sample/example code available to show me how?
While not in Python, you can review the C++ code used by the Rotate Feature map tool.
Note:
The tool is interactive, so it uses the user input press and move events (e.g. like with a mouse) to calculate the degree of rotation to be applied.
The QgsMapToolRotateFeature::canvasReleaseEvent, where the calculated rotation is applied to the feature, is probably the code you are looking for.
canvasReleaseEvent function. L203-210 define the affine transformation, L224-243 apply the transformation to each point in the geometry. This is what you'd need. Or, as you say, you can do it using Shapely.
– Snorfalorpagus
Mar 19 '15 at 10:16
It can be accomplish, by using a python package named shapely.
Eg: shapely.affinity.rotate(ring,degres,origin='centroid',use_radians=False)