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 <[email protected] <mailto:[email protected]>> wrote:


    On Aug 26, 2013, at 12:50 PM, Oyvind Idland
    <[email protected] <mailto:[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] <mailto:[email protected]>
    http://lists.osgeo.org/mailman/listinfo/gdal-dev




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

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

Reply via email to