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)
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:
mapX,mapY,pixelX,pixelY,enable 6552733.64613180514425039,5073946.04477077350020409,6552533.84482758585363626,5074021.48275862075388432,1 6552633.32449856773018837,5071059.01110315229743719,6552461.44827586226165295,5071104.32758620660752058,1 6555111.64040114637464285,5073678.52041547279804945,6554765.36206896603107452,5073821.32758620660752058,1 6555249.11819484271109104,5071965.62141833826899529,6554833.5,5071973.08620689623057842,1
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
Corner Coordinates: Upper Left ( -591887.923, 223739.838) ( 35d 8'28.93"W, 1d14'58.74"N)
By the way, I also tried adding
-s_srs EPSG:31276 and
-a_srs EPSG:31276 and various combinations thereof to the gdal commands, but it didn't fix the problem.