[gdal-dev] Geotransform - rotation and translation
Jan Hartmann
j.l.h.hartmann at uva.nl
Tue Aug 27 00:10:22 PDT 2013
The only way would be then to concatenate the transformations: first
rotate and then translate half a pixel width. The computation can be
simplified by matrix multiplication:
http://www.mathplanet.com/education/geometry/transformations/transformation-using-matrices
Jan
> That won't work, since it will move the corner point half a cell, and
> then rotate around the new corner.
>
> - Øyvind
>
>
> On Mon, Aug 26, 2013 at 7:02 PM, Norman Vine <nhv at cape.com
> <mailto:nhv at cape.com>> wrote:
>
>
> On Aug 26, 2013, at 12:50 PM, Oyvind Idland
> <oyvind.idland at gmail.com <mailto:oyvind.idland at gmail.com>> 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
> gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130827/4ad8f3e1/attachment-0001.html>
More information about the gdal-dev
mailing list