<div dir="ltr">I am not sure, but I guess that you have to negate also GT5: y axis is reversed between image coordinates and "geographic" coordinates.<br clear="all"><div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">.___ ._ ..._ .. . ._. .___ .. __ . _. . __.. ... .... ._ .__<br>Entre dos pensamientos racionales <br>hay infinitos pensamientos irracionales.<br><br></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 21 Dec 2020 at 14:57, G Seiffert <<a href="mailto:hh1@posteo.de">hh1@posteo.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>Thanks Javier. Need to confess: math is not
my strong side. I'm more the "trial and error" guy. And - shame on me -
Google.<br>
<br>
Got the rotation AND the scaling correct meanwhile, calculating the
params as described here:
<a href="https://gis.stackexchange.com/questions/69715/rotating-rasters-using-gdal-geotransform-and-arcgis-desktop?noredirect=1&lq=1" target="_blank">https://gis.stackexchange.com/questions/69715/rotating-rasters-using-gdal-geotransform-and-arcgis-desktop?noredirect=1&lq=1</a><br>
<br>
Below a code snippet (I work in Python). However, with the exact calcs
from above website, my pics were rotated correctly but for some strange
reason mirrored vertically! Try and error: Making GT(4) negative got rid
of the mirroring. So almost happy now, just facing a weird shift of 2m
to west and 0.7m to south, working on it. <br>
<br>
# ROTATION PART Start ================================================<br>
rot_deg = 90<br>
rotation = np.deg2rad(rot_deg)<br>
<br>
GT0 = orig_x<br>
GT1 = math.cos(rotation) * image_resolution<br>
GT2 = -math.sin(rotation) * image_resolution<br>
GT3 = orig_y<br>
GT4 = <span style="font-size:18px"><span style="font-weight:bold">-</span></span>math.sin(rotation) * image_resolution<br>
GT5 = math.cos(rotation) * image_resolution<br>
<br>
geotrans = (GT0, GT1, GT2, GT3, GT4, GT5)<br>
<br>
# ROTATION PART End ================================================<br>
<br>
Thanks so far! Also Thomas and Jukka!<br>
Gerhard <br>
<span>
</span><br>
<blockquote type="cite" style="border:0px none">
<div style="margin:30px 25px 10px"><div style="width:100%;border-top:2px solid rgba(146,154,163,0.7);padding-top:10px"> <div style="display:inline-block;white-space:nowrap;vertical-align:middle;width:49%">
<a style="color:rgb(72,86,100);padding-right:6px;font-weight:500;text-decoration:none" href="mailto:j1@jimenezshaw.com" target="_blank">Javier
Jimenez Shaw</a></div> <div style="display:inline-block;white-space:nowrap;vertical-align:middle;width:48%;text-align:right"> <font color="#909AA4"><span style="padding-left:6px">21
December 2020 10:55</span></font></div> </div></div>
<div style="color:rgb(144,154,164);margin-left:24px;margin-right:24px">
<div dir="ltr"><div>Those transformation parameters can be seen as a 3x3
transformation matrix like this</div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Xg GT1 GT2 GT0 Xp</span></div><div><span style="font-family:monospace">Yg = GT4 GT5 GT3 * Yp</span></div><div><span style="font-family:monospace"> 1 0 0 1 1<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"><span style="font-family:arial,sans-serif">Where
<span style="font-family:monospace">[Xp, Yp]</span> is the coordinate
in pixels, and <span style="font-family:monospace">[Xg, Yg]</span> is
the "geographic" coordinate (whatever it means ;)</span><br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">the 2x2 top left corner of the
transformation matrix can be seen as a 2D rotation-scaling matrix: <a href="https://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2_dimensions" target="_blank">https://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2_dimensions</a><br><span style="font-family:monospace">[GT0, GT3]<span style="font-family:arial,sans-serif"> is the "geographic" coordinate of
the pixel </span>[0, 0]<span style="font-family:arial,sans-serif">
(regardless rotation or scaling)</span><br></span></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"><span style="font-family:arial,sans-serif">Cheers</span><br></span></div><div><div><div dir="ltr">.___
._ ..._ .. . ._. .___ .. __ . _. . __.. ... .... ._ .__<br>Entre dos
pensamientos racionales <br>hay infinitos pensamientos irracionales.<br><br></div></div><br></div></div><br>
</div>
<div style="margin:30px 25px 10px"><div style="width:100%;border-top:2px solid rgba(146,154,163,0.7);padding-top:10px"> <div style="display:inline-block;white-space:nowrap;vertical-align:middle;width:49%">
<a style="color:rgb(72,86,100);padding-right:6px;font-weight:500;text-decoration:none" href="mailto:hh1@posteo.de" target="_blank">G
Seiffert</a></div> <div style="display:inline-block;white-space:nowrap;vertical-align:middle;width:48%;text-align:right"> <font color="#909AA4"><span style="padding-left:6px">21
December 2020 10:24</span></font></div> </div></div>
<div style="color:rgb(144,154,164);margin-left:24px;margin-right:24px">
Hi all from GDLA.<br>
<br>
Thanks for the opportunity to as a question. It's regarding the <span style="font-weight:bold">Geotransform Tutorial</span><span style="font-weight:bold"> </span>(<a href="https://gdal.org/tutorials/geotransforms_tut.html" target="_blank">https://gdal.org/tutorials/geotransforms_tut.html</a>).
Tried to get info in the web but since this seems a tricky one, my
searches failed.<br>
<br>
The tutorial only deals with the ideal case of 'North up' images, for
which GT(2) and GT(4) are zero. However, my images are 'East up' and
potentially 'any direction up' (underwater photomosaic surveys by ROV).
The rotation works with '90' for GT(2, 4). But the scaling seems
completely ignored. Any hint? If it would be easy, I assume your
tutorial would give an example for how to deal with "non-N-up' images,
but ...<br>
<br>
My pics are 1920x1080, with pixel resolution of 0.0015 (yes, 0.15cm per
pixel, we're flying just 3m above the bottom).<br>
<br>
In case I rotate the images prior to geotransform (in Photoshop),
geotransform works perfect, with GT(2, 4) = 0. Scaling spot on. I can
live with that for our last survey but I'm also looking for a solution
in case our survey heading cannot be 0, 90, 180, or 270, but has to be
something like 35° (due to bottom currents etc.).<br>
<br>
Best regards, any hint qappreciated,<br>
Gerhard<br>
<br>
<br>
</div>
</blockquote>
<br>
</div>
</blockquote></div>