[Gdal-dev] Georeferencing an image using gdalwarp: format of GCPs?

Frank Warmerdam warmerdam at pobox.com
Thu Jul 27 07:41:43 EDT 2006


wqual wrote:
> Hi list,
> I have several scanned maps that I would like to give real coordinates using 
> gdalwarp: after creating a GCS-file (a text file with four columns x_image 
> y_image, east_coordinates, north_coordinates), I tried the following command:
> 
> wqual at standalone:~$ gdalwarp -t_srs /home/wqual/karte_GCP.txt Input_1.jpg 
> output.tif
> 
> But the only thing I get is:
> ERROR 1: Translating source or target SRS failed:
> /home/wqual/karte_GCP.txt
> 
> Question therefore: what is the correct format of a GCS-file which can be read 
> by gdalwarp? I would be glad to receive any comments on this.

Wolfgang,

I don't believe gdalwarp supports having gcps supplied on the commandline.
So you end up having to use gdal_translate first to add gcps to a file.

eg.
gdal_translate -gcp 0 0 -117.25 33.0     -gcp 1000 0 -117 33.0 \
                -gcp 0 1000 -117.25 32.75 -gcp 1000 1000 -117 32.75 \
                Input_1.jpg Input_1_gcps.tif
gdalwarp Input_1_gcps.tif output.tif

You can also place the gcps in a file, and use the --optfile switch to
reference the file.  For instance if your karte_GCP.txt contained:

-gcp 0 0 -117.25 33.0
-gcp 1000 0 -117 33.0
-gcp 0 1000 -117.25 32.75
-gcp 1000 1000 -117 32.75

then you could do:

gdal_translate --optfile karte_GCP.txt Input_1.jpg Input_1_gcps.tif

Keep in mind that the gcp arguments are "pixel line geo_x geo_y".

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org




More information about the Gdal-dev mailing list