<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 26, 2013, at 12:50 PM, Oyvind Idland <<a href="mailto:oyvind.idland@gmail.com">oyvind.idland@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div>I am currently working on a driver for a proprietary format, which is being consumed by ArcGis via GDAL.<br><br></div>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: <br>
<br>poDS->dGeoTransform[0] = originX;<br>poDS->dGeoTransform[1] = cos(rotation) * cellSizeX;<br>poDS->dGeoTransform[2] = -sin(rotation) * cellSizeX;<br>poDS->dGeoTransform[3] = originY;<br>poDS->dGeoTransform[4] = sin(rotation) * cellSizeY;<br>
poDS->dGeoTransform[5] = cos(rotation) * cellSizeY;<br><br></div>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.<br>
<br></div><div>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:<br>The cyan dot shows the pivot point:<br>
<br><a href="http://i.stack.imgur.com/7HEvc.png">http://i.stack.imgur.com/7HEvc.png</a><br></div><div></div><div><br><br></div>Is there any way to express this translation using the geotransform matrix ?<br></div></blockquote><div><br></div><div>I think this should work</div><div><div><br></div><div>poDS->dGeoTransform[0] = originX + cellSizeX/2.0;</div><div>poDS->dGeoTransform[1] = cos(rotation) * cellSizeX;</div><div>poDS->dGeoTransform[2] = -sin(rotation) * cellSizeX;</div><div>poDS->dGeoTransform[3] = originY - cellSizeY/2.0;</div><div>poDS->dGeoTransform[4] = sin(rotation) * cellSizeY;</div><div>poDS->dGeoTransform[5] = cos(rotation) * cellSizeY;</div><div><br></div><div><br></div></div></div></body></html>