On Aug 26, 2013, at 12:50 PM, Oyvind Idland <[email protected]> wrote:

> I am currently working on a driver for a proprietary format, which is being 
> consumed by ArcGis via GDAL.
> 
> These grids sometimes has a rotation with a specified pivot point. I managed 
> to get ArcGis to display the rotated grid by doing the following: 
> 
> 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;
> 
> Rotation is in radians. It works, but there is one problem: I need to rotate 
> the grid around the center of the corner cell (originX, originY), but ends up 
> getting rotation around the corner of the cell/raster instead.
> 
> There is a screenshot here, showing only the corner pixel. The topmost 
> grid/pixel was translated using custom geotransform in ArcGis, the bottom one 
> is the result of my GDAL rotation:
> The cyan dot shows the pivot point:
> 
> http://i.stack.imgur.com/7HEvc.png
> 
> 
> Is there any way to express this translation using the geotransform matrix ?

I think this should work

poDS->dGeoTransform[0] = originX + cellSizeX/2.0;
poDS->dGeoTransform[1] = cos(rotation) * cellSizeX;
poDS->dGeoTransform[2] = -sin(rotation) * cellSizeX;
poDS->dGeoTransform[3] = originY - cellSizeY/2.0;
poDS->dGeoTransform[4] = sin(rotation) * cellSizeY;
poDS->dGeoTransform[5] = cos(rotation) * cellSizeY;


_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to