I would like to georeference an image with GDAL. The image already has a spatial reference set (EPSG:31276). For the georeferencing, I have a list of 4 ground control points (also in EPSG:31276).

Using the QGIS Georeferencer Plugin, I can correctly georeference the image. I then select "Generate GDAL Script", which results in the following GDAL commands:

gdal_translate -of GTiff -gcp 6.55253e+06 -5.07402e+06 6.55273e+06 5.07395e+06 -gcp 6.55246e+06 -5.0711e+06 6.55263e+06 5.07106e+06 -gcp 6.55477e+06 -5.07382e+06 6.55511e+06 5.07368e+06 -gcp 6.55483e+06 -5.07197e+06 6.55525e+06 5.07197e+06 "C:/gis_sample_data/sample_image/image1.tif" "C:/Users/XYZ/AppData/Local/Temp/image1.tif"

gdalwarp -r near -order 1 -co COMPRESS=NONE  "C:/Users/XYZ/AppData/Local/Temp/image1.tif" "C:/gis_sample_data/sample_image/image1_georef.tif"

Those commands run without an error, but the resulting image is not correctly projected. Here is a small part from gdalinfo "C:/gis_sample_data/sample_image/image1.tif" (the original image):

Corner Coordinates:
Upper Left  ( 6551897.000, 5074277.000) ( 18d40' 4.21"E, 45d48'39.73"N)

whereas gdalinfo "C:/gis_sample_data/sample_image/image1_georef.tif" (result from the GDAL call) shows

Corner Coordinates:
Upper Left  ( -534350.794,  156938.268) ( 34d51'24.74"W,  0d52'47.63"N)

How would I have to modify the GDAL commands to correctly georeference the image?

The sample image is part of the Baranja Hill data set, which can be downloaded from here. The ground control points are those:


When copied into a text editor and saved with the .points extension, they can be imported in the QGIS Georeference Plugin.

EDIT: Changed negative to positive values in gdal_translate. Results of gdalinfo:

Corner Coordinates:
Upper Left  ( -591887.923,  223739.838) ( 35d 8'28.93"W,  1d14'58.74"N)

By the way, I also tried adding -t_srs EPSG:31276, -s_srs EPSG:31276 and -a_srs EPSG:31276 and various combinations thereof to the gdal commands, but it didn't fix the problem.


The coordinates in your gdal_translate command should be all positive.

The GCP list is, so I think this could be a bug of the GDAL script creator.


I could replicate your error, and think that your use case is not the intended use of GCP.

In "normal" georeferencing, the GCP points map pixel coordinates from an unreferenced picture to projected or geographical coordinates. The pixel coordinates are relative to the upper left corner.

In your use case, you take projected coordinates from a georeferenced tif, and compare them to "correct" coordinates. The coordinates on the left side are not relative to the upper left corner, but to the origin of the projection. If you start the reprojection process, this information will be distroyed and replaced by the GCP information. This does not seem to work.

In the GDAL batch file, you can add -of VRT to get vrt instead of tif files. You can open those vrt in a text editor and see that the matching goes terribly wrong.

  • Indeed, the sample data is well georeferenced and my invented GCPs would introduce an erroneous shift to the east. However, my real data is badly georeferenced and the real GCPs would correct that. Concerning your other remark, I'll update the question. – Jon Snow Mar 14 '14 at 9:22
  • I think EPSG:31276 is generally a bad idea for Croatia. Where is your real data from? – AndreJ Mar 14 '14 at 9:45
  • My real data is from Africa and we use WGS 84 / UTM. I could replicate the problem I described with multiple sample data sets from different places around the world and different CRS, so I don't think that it is specific to one CRS. – Jon Snow Mar 14 '14 at 12:53
  • I think your problem lies somewhere else. See my extended answer. – AndreJ Mar 14 '14 at 16:57
  • Thanks for your answer. It's good to know that it's simply not possible, so I can stop searching for the solution. ;) – Jon Snow Mar 17 '14 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.