﻿ The Affine 4 parameters transformation
 The Affine 4 parameters transformation - Basic Concepts The geometrical state of a non-geo-referenced raster map is summarized by Fig. BC.A1 (where the disorientation angle has been abnormally increased only for making it evident). The raster has its own reference system with origin (0,0) in its lower-left vertex and the vertical axis is not parallel to the map’s North axis (Disorientation). In addition, the raster units are the image pixels, not meters. As explained in section Basic concepts | What does it exactly mean to geo-reference a raster map, if we do not consider the map deformation, our goal is to position the raster at the real map coordinates, correct the orientation error and transform the units from pixel into meters. The Affine 4 parameters transformation that we’ll see in this section is one of the possible methods to achieve this result.   Fig. BC.A1 – The initial state of a non-geo-referenced map.   The algorithm consists in a roto-translation between two reference systems: the raster and the map. Mathematically, to transform the coordinates from one reference system to another, at least the coordinates of 2 points in both systems are needed. We need at least 2 points, thus 4 coordinates as known values, because we have to solve 4 simultaneous equations as we’ll see below. Fig. BC.A2 shows the roto-translation schema: E0 and NO are the East/North translations between the origin of the raster system (red axis) and the origin of the map system (blue axis), whereas ε is the rotation angle between the two systems. Fig. BC.A2 – The geometrical schema of the roto-translation between two reference systems.   To transform raster coordinates of points P and Q into their corresponding map coordinates, we need to apply the following formulae: Now substituting distances AC, AB, PC, BO’, DF, DE, QF, EO’, by calculating them from raster coordinates xp, yp and the rotation angle ε, the formulas become: Even though two known points in both systems are sufficient to solve this transformation, it is obviously advised to use more points in order to have a more accurate calculation. Using more than two points implies that a scale factor between the two systems is generated due to the surplus of measurements. For example, adding a third point R to the calculation, the scale factor f further transforms the equations as thus: For a generic point P these equations can be conveniently written in matrix form as follows: This notation makes quite clear why this transformation is called “4 Parameters”, there are in fact 4 values we need to calculate in order to transform the raster coordinates of one point into its corresponding map coordinates. These 4 parameters are: E0, N0, f, ε, i.e. the two East/North translations of the raster origin, the scale factor and the rotation angle. How do we calculate these four parameters? We obviously need to solve the set of equations (1) above. But this set is over-determined because there are more equations than unknowns, therefore the solution cannot be unique but approximate and each equation will leave a residual instead of zero. In this example there are 6 equations and 4 unknowns, but obviously the number of equations is usually much bigger, being twice the number of known points in both raster and map systems. The couple of equations of a generic point P results:   Where Δe and Δn are the above mentioned residuals. The solution of such a set of equations is obtained by applying the “Least Squares” method which minimizes the sum of the squares of the residuals resulting for every single equation. Of course, the full explanation of this solution goes beyond the purpose of this guide. So, with the sequence of images below we simply show the 4 transformation parameters, i.e. the 4 movements that we need to apply to the raster in order to solve the geo-referencing.   Fig. BC.A3 – The East translation (1st parameter) moves the raster origin to its real map East coordinate.   Fig. BC.A4 – The North translation (2nd parameter) moves the raster origin to its real map North coordinate.   Fig. BC.A5 – The Rotation (3rd parameter) rotates the raster so that it matches the real map North direction.     Fig. BC.A6 – The Scale factor (4th parameter) magnifies or reduces the raster transforming its units from pixels to meters.   Regarding this last 4th parameter, it must be said that this transformation applies a unique scale factor. This means that the raster magnification or reduction is “isotropic”, i.e. equal in both East and North directions. This has to be mentioned because there is also an “Affine 5 parameters transformation” in which 2 separate scale factors are calculated, one for East and one for North direction. This last algorithm is preferred when you assume that the raster map has been subjected to a different deformation in the two directions, as it normally happens, for example, when a low quality rolling scanner is used. To understand the difference between a unique and two scale factors, just think of when you have an image inside an image-editing software package. If, for example, you want to enlarge it, you can act in two ways: by dragging the grip on one of its vertices or dragging the grip on one of the middle points of its sides. In the first case the image will enlarge maintaining its aspect ratio, in the second case it will enlarge only in the direction you are dragging it (vertically or horizontally), whereas the other size remains unaltered, thus producing a distortion of the aspect ratio.   In the Transformations | Affine section you'll find a practical example on how to perform this transformation with CorrMap.