# Rotating a point grid in QGIS Good ol’ GIS.stackexchange … I finally ended up posting a bounty of 50 reputation points for my rotation problem, and got an answer within a couple of hours! If you want to rotate a grid of points around (originX, originY) and degrees θ, enter the following values into the dialog (see image to the right):

 Scale X cos(θ) Rotation Y -sin(θ) Translation X originX – cos(θ) * originX + sin(θ) * originY Rotation X sin(θ) Scale Y cos(θ) Translation Y originY – sin(θ) * originX – cos(θ) * originY

Here’s an R function to give you 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)
}

The respondent on GIS.SE initially gave a PostGIS (>v.1.5) function which would do the job – ST_Rotate:

SELECT ST_Rotate(geom, θ*pi()/180, originX, originY)

I really want a solution which works just in QGIS, so for the moment am going to use the qgsAffine plugin, even though it’s a bit clunky to have to do the calcs, and the plugin itself seems buggy.

However, it should be possible to build a rotation function in spatialite, which comes installed with QGIS.

## One Comment

1. João

Hi, i’m trying to work with this tool to rotate a vector point grid, I calculate with a spreedsheet de values of rotation, scale and translation but when I run the vector affine transformation, the geometry of vector point grid do the rotation but change the location of the grid.

My coordinate System is: ESPG:2743 – Datum 73 /Modified Portuguese Grid.

This are the characteristics of the grid:
+proj=tmerc +lat_0=39.66666666666666 +lon_0=-8.131906111111112 +k=1 +x_0=180.598 +y_0=-86.98999999999999 +ellps=intl +towgs84=-223.237,110.193,36.649,0,0,0,0 +units=m +no_defs