Changes between Version 7 and Version 8 of DevWikiAffineParameters
- Timestamp:
- 11/27/11 12:51:20 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevWikiAffineParameters
v7 v8 3 3 == Introduction == 4 4 5 Geospatial rasters inherently have two coordinate systems associated with them: pixel indices and real world coordinates. Although some rasters have a very complex relationship between these two coordinate systems, many have a set of simple linear relationships between the two coordinate systems. These simple linear relationships are ''modular'' and may be combined in many ways. Regardless of the order in which they are combined, an affine transform results. The transform is then used to convert coordinates between the two coordinate systems of the raster. This page describes a set of ubiquitous individual transformations and demonstrates how they may be combined to produce an affine transformation. 5 Geospatial rasters inherently have two coordinate systems associated with them: pixel indices (i,j) and real world coordinates (x,y). For the simple case covered on this page, where a linear transform is sufficient to relate the two coordinate systems, physically significant parameters may be used to define the linear relation. These physically significant parameters control the magnitude and orientation of the basis vectors '''i,,b,,''' and '''j,,b,,''' defined in the following figure: 6 7 [[Image(construction-step5.png)]] 8 9 10 Although some rasters have a very complex relationship between these two coordinate systems, many have a set of simple linear relationships between the two coordinate systems. These simple linear relationships are ''modular'' and may be combined in many ways. Regardless of the order in which they are combined, an affine transform results. The transform is then used to convert coordinates between the two coordinate systems of the raster. This page describes a set of ubiquitous individual transformations and combines them to produce a specific affine transformation which adheres to the . 6 11 7 12 The level of math required to follow along is advanced high school algebra or introductory college algebra. It should be accessible to anyone with a science, math, or engineering background. Lacking this, the nontechnical introduction to [http://en.wikipedia.org/wiki/Matrix_multiplication matrix multiplication] on wikipedia should provide sufficient background. … … 9 14 == Individual operations == 10 15 11 This page discusses operations in two dimensions only. Each operation is presented as a 2x2 matrix, and each operation performs only one function. These operations were taken from [http://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2D_graphics wikipedia]. While the matrices presented here contain the bulk of the functionality of a finished affine transform, they are not ''complete'' affine transforms themselves. Each transformation will be presented in matrix and equation form: they are equiv ilent representations.16 This page discusses operations in two dimensions only. Each operation is presented as a 2x2 matrix, and each operation performs only one function. These operations were taken from [http://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2D_graphics wikipedia]. While the matrices presented here contain the bulk of the functionality of a finished affine transform, they are not ''complete'' affine transforms themselves. Each transformation will be presented in matrix and equation form: they are equivalent representations. 12 17 13 18 === Rotation === … … 54 59 * y' = k,,y,,x + y 55 60 61 === Reflection === 62 63 Reflection across the x axis (or "flipping" the y axis) is accomplished with the following transform: 64 65 [[Image(reflect_x.png)]] 66 67 * x' = x 68 * y' = -y 69 70 56 71 == Combining individual operations == 57 72 58 Whenever more than one of the above operations is required, they may be combined using [http://en.wikipedia.org/wiki/Matrix_multiplication matrix multiplication]. As an example, all of the above matrices will be combined into one. The result of such a combination is still not an affine transform, however. It is just a 2x2 matrix has all the individual functions aggregated into it.73 Whenever more than one of the above operations is required, they may be combined using [http://en.wikipedia.org/wiki/Matrix_multiplication matrix multiplication]. As an example, all of the above matrices will be combined into one. The result of such a combination is still not an affine transform, however. It is just a 2x2 matrix which has all the individual transformation functions aggregated into it. 59 74 60 75 We will be calculating a new matrix, '''O''', which is the aggregate of the following individual operations: 61 76 62 1. scaling63 1. clockwise rotation around the origin64 1. shearing parallel to the xaxis65 1. shearing parallel to the y axis77 1. Reflection across the i axis 78 1. Scaling along the i and j axes 79 1. Shearing parallel to the i axis 80 1. clockwise rotation around the origin (by θ,,i,,) 66 81 67 82 We do this by multiplying the 2x2 matrices of the individual operations together, as follows: … … 69 84 [[Image(aggregate_step1.png)]] 70 85 71 The above matrix equation is shorthand for four equations: one equation each for o,,11,,, o,,12,,, o,,21,, and o,,22,,. We will perform themultiplications on the right hand side one at a time.86 We will perform the matrix multiplications on the right hand side one at a time. 72 87 73 88 [[Image(aggregate_step2.png)]] … … 77 92 [[Image(aggregate_step4.png)]] 78 93 79 * o,,11,, = s,,x,, ( (1 + k,,x,, k,,y,,) cosθ + k,,y,, sinθ ) 80 * o,,12,, = s,,x,, ( k,,x,, cosθ + sinθ ) 81 * o,,21,, = s,,y,, ( -(1 + k,,x,, k,,y,,) sinθ + k,,y,, cosθ ) 82 * o,,22,, = s,,y,, ( - k,,x,, sinθ + cosθ ) 94 The above matrix equation is shorthand for four equations: one equation each for o,,11,,, o,,12,,, o,,21,, and o,,22,,. 83 95 84 Notice that none of the coefficients in the '''O''' matrix may be said to represent pure scaling, rotation or shearing. Rather, they all have components of each of these operations factored in. If a particular transformation is not needed (say there is no shearing in either the x or y directions), then the relevant parameters may be set to zero (k,,x,, = k,,y,, = 0). 96 * o,,11,, = s,,i,, cos(θ,,i,,) 97 * o,,12,, = k,,i,, s,,j,, f cos(θ,,i,,) + s,,j,, f sin(θ,,i,,) 98 * o,,21,, = -s,,i,, sin(θ,,i,,) 99 * o,,22,, = -k,,i,, s,,j,, f sin(θ,,i,,) + s,,j,, f cos(θ,,i,,) 100 101 Notice that none of the coefficients in the '''O''' matrix may be said to represent pure scaling, rotation or shearing. Rather, they all have components of each of these operations factored in. The final matrix equation has some terms which need to be calculated. This will be performed in the next section using the real input parameters. Once these terms have been calculated, they may be plugged into the above equations to arrive at the coefficients which must be stored in the geotransform matrix. 85 102 86 103 Also notice that it is not necessary to compute this matrix every time one wants to convert between pixel indices and geographic location. The coefficients are computed once for the entire raster, and may be reused for every pixel calculation. You would use this aggregate matrix '''O''' exactly as you would use any of the individual matrices: … … 88 105 [[Image(aggregate_usage.png)]] 89 106 90 * x' = o,,11,, x + o,,12,, y91 * y' = o,,21,, x + o,,22,, y107 * x' = o,,11,, i + o,,12,, j 108 * y' = o,,21,, i + o,,22,, j 92 109 93 110 == Constructing the affine transformation ==