<br>Dear QGIS users,<br><br>Summary: I'm running the Georeferencer plugin 3.1.9 with QGIS 1.6.0 and it<br>doesn't work correctly -- the raster is distorted and plotted in the wrong<br>location. However, I found a work-around that fools the plugin into giving<br>
correct results, and appears to point out a serious bug in the plugin. (Or, I'm<br>doing something wrong -- please let me know.)<br><br>(And please tell me if I've posted this in the wrong place.)<br><br>Suppose I have an image called "input.tif" that has some geospatial metadata<br>
with a CRS and image bounds. For the following discussion, here are the<br>relevant lines that result from running "gdalinfo input.tif":<br><br>Size is 1101, 1091<br>...<br>Upper Left ( 4578.469, -13361.035) ( 5d26'57.36"W, 2d10'18.28"S)<br>
Lower Left ( 4578.469, -13652.219) ( 5d26'57.36"W, 2d10'35.98"S)<br>Upper Right ( 4872.322, -13361.035) ( 5d26'39.49"W, 2d10'18.28"S)<br>Lower Right ( 4872.322, -13652.219) ( 5d26'39.49"W, 2d10'35.98"S)<br>
Center ( 4725.395, -13506.627) ( 5d26'48.43"W, 2d10'27.13"S)<br><br>Now suppose I open the Georeferencer and open this image, and define a<br>transformation (say, "polynomial 1") with three ground control points (GCPs).<br>
When I tell it to "start georeferencing" and to load the result into my QGIS<br>project, the image is hugely distorted and located in the wrong place. I found<br>a BIG CLUE about what's happening when I asked it to "generate GDAL script".<br>
The result was:<br><br>gdal_translate -of GTiff -gcp 4690.78 13510.5 4434.32 -13412.7 \<br> -gcp 4721.32 13469.4 4462.09 -13371.6 \<br> -gcp 4753.5 13539.4 4497.52 -13458.7 \<br>
-gcp 4692 13536.2 4430.49 -13445.3 \<br> "/path/input.tif" "/tmp/input.tif" <br><br>gdalwarp -r cubic -order 1 -co COMPRESS=NONE "/tmp/input.tif" \<br>
"/path/output.tif"<br><br>But if we look at the man pages for gdal_translate, the format for input of GCPs<br>is:<br><br>-gcp pixel line easting northing elevation<br><br>The first argument to "-gcp" should be the x coordinate in *image* space, not in<br>
*coordinate* space. It should be the column number of the pixel in question (I<br>don't know if it can be a floating point; hopefully it can). The second<br>argument to "-gcp" has to be the *row* number of the pixel in the image being<br>
georeferenced. The "easting" and "northing" are indeed the x and y coordinates<br>in the target coordinate system. But notice that in the gdal_translate command<br>that the Georeferencer generated, the first two arguments are positions in<br>
coordinate space, not image space!<br><br>So, here's the work-around. We saw above that the size of the image is 1101 x<br>1091. All we have to do is change the bounds of the input image so that the<br>image's geographic coordinates match the image space coordinates. We can do<br>
that easily with gdal_translate, being careful to account for QGIS using a<br>positive-up y-axis. Here's the command for the current case:<br><br>gdal_translate -of GTiff -a_ullr 0 0 1100 -1090 input.tif input_fixed.tif<br>
<br>Now, when we open the new input image (input_fixed.tif) into the Georeferencer <br>and select GCPs, etc, it actually works!<br><br>M<br><br><br>