I am trying wrap my raster with GCP control points using gdal_translate and gdalwrap tools. I've read at gdal mailing list about wrap with affine transformation, so I thought it is easy to done using GCP control points and TPS transformation. I've Tif file with tfw file in WGS_84 coordinate system.

First I've create template vrt file using my orginal file like this:

gdal_translate orginal.tif temp.vrt -of VRT

Next, I've edited vrt file, where I added as a elements inside VRTDataset element code that is shown below:

<GCPList Projection="EPSG:4326">
 <GCP Id="1"     Pixcel="5650959.808031" Line="4432086.318384"   X="4432215.141964" Y="5650933.901849" />

where I wrote gcp with this scheme:

<GCP Id="unique number etc. 1, 2"    Pixcel="x_source" Line="y_source"   X="x_target" Y="y_target" />

EDIT: For x_source, y_source, x_target, y_target I use geographic coordination x, y value source or target

In next step I similarly as at linked post I've used gdal_translate again: gdal_translate temp.vrt out.tif

Finally, I try execute gdalwrap using:

gdalwarp src.tif out.tif -tps

but this process are aborted with error code:

ERROR 1: Unable to compute a GCP_TPS based transformation between pixel/line and georeferenced coordinates for out.tif

I want to wrap my image using control points, as a result which transform using gcp control points. What should I do to get wrap image with georeference?

Note: Moreover, If easy solution is algorithm I may can write C++ code

  • Did you really write it as Pixcel="x_source" and do you really have so huge image with over five million columns and over four million lines Pixcel="5650959.808031" Line="4432086.318384"? Btw. you deal with warping, not wrapping. – user30184 Feb 28 at 14:15
  • @user30184 I haven't a big image. I've used x, y source represented by geographic coordinates. If I understand well your comment, will I should use image pixel coordinates? How I should write example line of GCP? – Lisek Feb 28 at 14:25
  • The top-left corner of the top-left pixel of the image has Pixel="0" and Line="0". – user30184 Feb 28 at 14:29
  • @user30184 Pixel represent y value and Line represent x value? Should for X and Y I set target X, Y position in geographic coordinates system which I want to use? – Lisek Feb 28 at 14:32
  • Gdal_translate manual gdal.org/gdal_translate.html documents the usage -gcp pixel line easting northing elevation: Add the indicated ground control point to the output dataset. This option may be provided multiple times to provide a set of GCPs. "Pixel" is image x, number of pixel from left to right and "Line" is image y, number of pixel from top to bottom. Coordinates are in the unit of the SRS, degrees for EPSG:4326, meters, feet etc. for some other coordinate systems. – user30184 Feb 28 at 14:37

Your Answer

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

Browse other questions tagged or ask your own question.