I am working on a GDAL driver for a proprietary grid-format. In some cases, the grids are rotated in order to get smaller file sizes. In my GDAL geotransform array, I do the following (showing a hardcoded 30 degrees angle):
rot_deg = 30;
rotation = rot_deg * deg2rad;
poDS->dGeoTransform[0] = originX;
poDS->dGeoTransform[1] = cos(rotation) * cellSizeX;
poDS->dGeoTransform[2] = -sin(rotation) * cellSizeX;
poDS->dGeoTransform[3] = originY;
poDS->dGeoTransform[4] = sin(rotation) * cellSizeY;
poDS->dGeoTransform[5] = cos(rotation) * cellSizeY;
where originX and originY is the center of the corner cell.
In addition, I got an identical file in TIFF format, with same min/max + cell values.I then apply an ArcGis geotransform to the .tiff, rotating it 30 degrees aswell.
When adding both files as layers, the tiff is 100% correctly aligned to the pivot point, while my GDAL format is slightly displaced.
The screenshot shows the overlapping grids, with only the corner pixel visible. The cyan point is the pivot point. The dark pixel on top is the (correct) tiff, while the grey pixel beneath is from my own driver. The misalignment is the same over the whole grid.
Anybody got an idea what could be wrong ?
In the ArcGis geotransform, it is possible to enter a pivot point, which is the case here (center of the corner cell). However, it seems like GDAL's geotransform is not expressive enough (?) to handle this, hence it uses the lower left corner.