Geographic raster (remote sensing images, Dem, scanned images, etc.) is an important data source in GIS. A large amount of raster data is generated every day, but the image itself only records the information of the image, if you want to establish an association with the actual geographic coordinates, you must specify the coefficients of the affine transformation. This is the most commonly used method for geometric correction. In the case of reserved parallelism, the affine transform allows rotation, translation, and uneven scaling of the rectangular target. The mathematical expression of the affine transform is:
X' = AX + by + c
Y' = dx + ey + F
Where:
X' = geographic X coordinates of pixels
Y' = geographic y coordinate of the pixel
X = pixel coordinates [column number]
Y = pixel coordinate [row number]
Pixel resolution in the = x direction
D. B = rotating system
E = pixel resolution in the Y direction
C = pixel center X coordinate in the upper left corner of the raster Map
F = Y coordinate of the pixel center in the upper left corner of the raster Map
The key is how to obtain these six coefficients. Generally, the most common method is to use the control points (generally four more) and obtain the coefficients through the least square method, in this way, the image coordinate can be converted to the actual coordinate. The suffix of the common TIFF format transformation coefficient file is tfw, which is actually a text file. The following is an actual example:
0.0000025009
0.0000000000
0.0000000000
-0.0000025009
111.8439114689
29.6483755683
The specific explanation is as follows. The first number of 0.0000025009 represents the pixel resolution in the X direction, that is, the actual distance represented by a pixel;
0.0000000000 of the numbers 2 and 3 represent the rotation coefficient;
The fourth number is-0.0000025009, which indicates the pixel resolution in the Y direction;
The fifth number 111.8439114689 represents the pixel center X coordinate in the upper left corner of the grid.
The sixth number is 29.6483755683, which represents the Y coordinate of the pixel center in the upper left corner of the grid.
Of course, some files are not divided into six lines, which need to be identified by yourself, and then divided into six lines to be clear.
In gdal, you can useCodeObtain these six coefficients:
// Obtain the coefficient of the affine transformation, double adfgeotransform [6]; podataset-> getgeotransform (adfgeotransform );
The above is just a brief description of what is added. I will try again later.
Adfgeotransform [0] x geographical coordinates in the upper left corner of the image
Adfgeotransform [1] x direction, that is, horizontal resolution size
Adfgeotransform [2]Rotation coefficient. If it is 0, it is the standard positive-North image.
Adfgeotransform [3] y geographic coordinates in the upper left corner of the image
Adfgeotransform [4]Rotation coefficient. If it is 0, it is the standard positive-North image.
Adfgeotransform [5]Y indicates the vertical resolution.
These six parameters can easily calculate the geographic coordinates of each pixel in the image. Of course, it is also easy to calculate the pixel coordinates based on geographic coordinates.