Thanks Javier, but as it looks the way I did works great. Got rid of the XY shift as well. Rotation affects the calculations for the origin as well, of course, this is what I needed to correct. In case of 0 vs 90 deg rotation the fix was simple. Will now work on trig formulas that work with any rotation angle.

G


Javier Jimenez Shaw <mailto:[email protected]>
21 December 2020 14:02
I am not sure, but I guess that you have to negate also GT5: y axis is reversed between image coordinates and "geographic" coordinates.
.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
Entre dos pensamientos racionales
hay infinitos pensamientos irracionales.



G Seiffert <mailto:[email protected]>
21 December 2020 12:57
Thanks Javier. Need to confess: math is not my strong side. I'm more the "trial and error" guy. And - shame on me - Google.

Got the rotation AND the scaling correct meanwhile, calculating the params as described here: https://gis.stackexchange.com/questions/69715/rotating-rasters-using-gdal-geotransform-and-arcgis-desktop?noredirect=1&lq=1

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.

# ROTATION PART Start ================================================
    rot_deg = 90
    rotation = np.deg2rad(rot_deg)

    GT0 = orig_x
    GT1 = math.cos(rotation) * image_resolution
    GT2 = -math.sin(rotation) * image_resolution
    GT3 = orig_y
    GT4 = -math.sin(rotation) * image_resolution
    GT5 = math.cos(rotation) * image_resolution

    geotrans = (GT0, GT1, GT2, GT3, GT4, GT5)

# ROTATION PART End ================================================

Thanks so far! Also Thomas and Jukka!
Gerhard




_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Javier Jimenez Shaw <mailto:[email protected]>
21 December 2020 10:55
Those transformation parameters can be seen as a 3x3 transformation matrix like this

Xg     GT1 GT2 GT0     Xp
Yg  =  GT4 GT5 GT3  *  Yp
 1      0   0   1       1

Where [Xp, Yp] is the coordinate in pixels, and [Xg, Yg] is the "geographic" coordinate (whatever it means ;)

the 2x2 top left corner of the transformation matrix can be seen as a 2D rotation-scaling matrix: https://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2_dimensions [GT0, GT3]is the "geographic" coordinate of the pixel [0, 0](regardless rotation or scaling)

Cheers
.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
Entre dos pensamientos racionales
hay infinitos pensamientos irracionales.



G Seiffert <mailto:[email protected]>
21 December 2020 10:24
Hi all from GDLA.

Thanks for the opportunity to as a question. It's regarding the Geotransform Tutorial(https://gdal.org/tutorials/geotransforms_tut.html). Tried to get info in the web but since this seems a tricky one, my searches failed.

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 ...

My pics are 1920x1080, with pixel resolution of 0.0015 (yes, 0.15cm per pixel, we're flying just 3m above the bottom).

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.).

Best regards, any hint qappreciated,
Gerhard




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

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

Reply via email to