Computing and applying an affine transformation to a vector layer using gvSIG and Quantum GIS

Geomatics Supervisor and Egyptian Archaeology PhD student Anna Hodgkinson told me that she is trying to apply an affine transformation to a set of coordinates. These are originally in an unknown local coordinate system. She has provided 4 reference points for which both the local coordinates and the EPSG:32636 coordinates are known:

ID ; EPSG_32636_X  ; EPSG_32636_Y   ; Local_X     ; Local_Y
1  ; 300646.885431 ; 3231905.223285 ; -144.333424 ; -50.678221
4  ; 300939.099675 ; 3232334.126771 ;  100.477740 ; 407.439814
7  ; 300519.458438 ; 3232235.904115 ; -304.216081 ; 262.236955
8  ; 300717.256565 ; 3232552.638076 ; -141.107317 ; 602.476276


First we need to compute which affine transformation takes the coordinates from the local grid to EPSG:32636. To achieve this, we can use the raster georeferencing tool in gvSIG since it lets you input by hand the source and target coordinates and then creates a WLD file whose 6 parameters are actually the affine transformation matrix. We'll use those 6 parameters to transform our vector layer (the local grid points):

In gvSIG, we create a view and add some layer so that gvSIG lets us start the raster georeference dialog. The "file to georeference" is irrelevant, just pick a random image from your computer:



Then enter the pairs of coordinates. The more coordinates the better, but at least three:


Then click on Apply and Exit, and gvSIG must have created a 6-line text file (probably *.wld or *.jpgw) next to the random image we used. In this case, the content of that file (called "the world file") is:

1.0001718355858875
0.10286004764601794
-0.11221180701761306
0.9922215770511519
300796.5805726947
3231940.256725514

Those are the 6 parameters of an affine transformation matrix. Now we switch to Quantum GIS [Juan, you are fired!] where we have installed this plugin. We can now add a shapefile with our vector features in the local coordinate system, start the editing mode and use the affine transformation plugin:



We'll see a little dialog where we must enter the 6 parameters we got using gvSIG. In reality, the dialog is a bit wrong in the sense that the first four parameters should not be called like that, because when you have a rotation angle which is not zero, the meaning of each parameter cannot be described by saying simply "Scale factor in the X axis" or "Rotation in the X axis". Anyway, this is the correspondence between the 6 parameters from the world file and the parameter names QGIS is using:

- Scale X is the 1st parameter in the world file.
- Scale Y is the 4th parameter
- Rotation X is the 3rd parameter
- Rotation Y is the 2nd parameter
- Translation X is the 5th parameter
- Translation Y is the 6th parameter

And that's it, the vector layer must have been transformed correctly and now should match the coordinates in EPSG:32636, with a little error of course which depends on how well the reference points were chosen and the accuracy of the coordinates provided.

Comments

  1. Very well discuss about affine transformation, an affine transformation is any transformation that preserves col-linearity and ratios of distances. In this sense, affine indicates a special class of projective transformations that do not move any objects from the affine space to the plane at infinity or conversely. An affine transformation is also called an affinity.
    math help online free

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Very nicely explained. This is some good work related to vector art services. Thank you very much...!

    ReplyDelete

Post a Comment

Popular posts from this blog

Transformación de CANOA (Venezuela) a WGS84 en gvSIG mediante una rejilla que simula el método Molodensky-Badekas