I would like to rotate a set of vector points in QGIS an arbitrary number of degrees around a central point (or arbitrary point).
This is similar to a recent question about creating a regular grid; it was suggested there to use the "Affine Transformation" tool (which I assume meant the plugin) to rotate or shift a grid of points an arbitrary angle or distance. I suspect I'm not understanding how it works, and haven't been able to get it to work.
I create a regular grid of points in QGIS, and ensure that the UTM zone is set correctly for both layer and project, enable editing for the layer, then open the plugin dialog (qgsAffine):
I select 'whole layer' and then, wanting to rotate the entire field of points by 15°, put 15 in both 'rotation' boxes (which may be where things are going wrong). The operation results in rotating the points somewhere off-planet!
Is this the right tool for the job? I would like to rotate a set of points about their common centre, ideally.
Update: qgsAffine is just a thought; if we can do this in any QGIS tool I'll be happy!
Update 2: qgsAffine is usable IF you know the right numbers to plug in (see answer below, thanks Mike!). Spreadsheet / calculator works fine, or here's the R function to get the numbers directly:
## Compute correct affine numbers for qgsAffine plugin
affine <- function(originX, originY, rotAngle) {
A <- rotAngle * pi / 180
scaleX <- scaleY <- cos(A)
rotX <- sin(A)
rotY <- -sin(A)
transX <- originX - cos(A) * originX + sin(A) * originY
transY <- originY - sin(A) * originX - cos(A) * originY
aff <- data.frame(scaleX, scaleY, rotX, rotY, transX, transY)
return(aff)
}
So, to rotate a grid of points in northern Uganda (UTM 36N), affine(578988, 419210, 30)
gives:
scaleX scaleY rotX rotY transX transY
1 0.8660254 0.8660254 0.5 -0.5 287174.7 -233330.5
... which, entered into the qgsAffine dialog, correctly rotates the points.