I want to generate a raster which is rotated with respect to its coordinate system. As I understand this requires modifying the geotransform array. I have not been able to find much information about this (though I did find a related SE question in Rotating rasters using GDAL Geotransform (and ArcGIS Desktop), and a thread on the GDAL-dev mailing list here, apparently started by the same person).
Most sites seem to only provide information on the structure of the unrotated geotransform. Based on the linked post & mailing list thread, I understand that the rotated geotransform should have the following elements:
 x-coordinate of upper-left raster corner  cos(θ) * x_resolution  -sin(θ) * x_resolution  y-coordinate of upper-left raster corner  sin(θ) * y_resolution  cos(θ) * y_resolution
However, I am not sure if this is correct.
I have tried using python to save a rotated raster using the above as a guideline for my geotransform, but the output is not what I expected. I defined my geotransform as:
# Define raster array to save array = np.arange(0,25).reshape(5,5) # Define rotation & geotransform rot = rot*math.pi/180 gt = (0,math.cos(rot)*x_res, -math.sin(rot)*x_res, 0, math.sin(rot)*y_res, math.cos(rot)*y_res) # Save raster save_raster(outfile, array, srs, gt)
And got the following result:
In a sense the raster has been 'rotated', but it appears my array has been resampled (which I do not want) while the raster cells are still aligned with the coordinate system x/y axes.
Am I just misunderstanding how the geotransform array works? Is there even a way to do what I am trying to do?