3

I have a tiff image and I would like to georeference it, and so create a Geotiff. To do that, I have to use GDAL. I use in particular, the executable store in the QGIS file (gdalwarp.exe, gdaltranslate.exe...).

For now, I use this code in a DOS command (command line), and this doesn't seem to work.

gdal_translate -of GTiff -gcp 33.9983 669.668 -833589 -692.339 -gcp 124.661 1377.97 -833520 -1379.2 -gcp 6788.34 -10.2993 -826876 6.06375 -gcp 6839.33 748.997 -826813 -755.83 -gcp 3014.52 363.682 -830651 -363.339 -gcp 3892.81 1032.32 -829762 -1021.34 "D:/Users/(...)/Desktop/image_projetee_UTM.tiff" "C:/Users/(...)/AppData/Local/Temp/image_projetee_UTM.tiff"

gdalwarp -r near -order 1 -co COMPRESS=NONE -dstalpha "C:/Users/(...)/AppData/Local/Temp/image_projetee_UTM.tiff" "D:/Users/(...)/Desktop/image_projetee_UTM_georef.tif"

1 - After run this code, the output image is not a GTiff but a Tiff like the input image.

2 - If I try to open the output image in Google Earth for example, it doesn't seems at all georeferenced

I think I missed something in the way to georeferenced a Tiff file...

Can anyone help me ?

  • 1
    At least gdalwarp does not know the projection at that state. Add -s_srs epsg:xxxx -t_srs epsg:xxxx where xxxx is the code of your UTM zone and GCPs as I suppose they are the same. And after each step use gdalinfo and check what metadata you have in each image. – user30184 Aug 20 '15 at 9:33
  • Are you sure your gcp values are correct? They don't look like UTM values, unless the data's near the equator. – mkennedy Aug 20 '15 at 16:58
  • Yes the image is located near the equator. I think my UTM coordinates are correct because QGIS gave it to me. @mkennedy – Manimalis Aug 21 '15 at 7:07
  • The pixel/line part of the gcp should always be positive. At least one of yours is not. And UTM coordinates should always be positive. – AndreJ Aug 21 '15 at 15:03
1

So, I succeed to georeference a tif file with GDAL with the use of 4 gcps (ground control points). To do this reprojection, I use gdal in command line.

First, use gdal translate like this :

gdal_translate -of GTiff -gcp 0 0 -6.848326  45.501053 -gcp 6862 0 -6.490975 45.501503 -gcp 0 1379 -6.762872 45.377363 -gcp 6862 1379 -6.545354 45.382523 "Inputimage.tif" "OutputImage.tif"

The ground control points are build like this : pixel coordinate in the image (x, y) and then geographical location (longitude, latitude).

I suggest to check with gdalinfo if the output file after gdaltranslate has been correctly fed with the gcps. With gdalinfo, you have to see in dos command something like that :

Coordinate System is `'
GCP Projection =
GCP[  0]: Id=1, Info=
          (0,0) -> (45.501053,-6.848326,0)
GCP[  1]: Id=2, Info=
          (6862,0) -> (45.501503,-6.490975,0)
GCP[  2]: Id=3, Info=
          (0,1379) -> (45.377363,-6.762872,0)
GCP[  3]: Id=4, Info=
          (6862,1379) -> (45.382523,-6.545354,0)

At this point, the image is not georeferenced yet. You have to use gdalwarp like this (there is several way to reproject, here I use "near" :

gdalwarp -r near -order 1 -co COMPRESS=NONE -dstalpha 
"OutputImageF_From_gdal_translate.tif" 
"FinalImage.tif"

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.