[Gdal-dev] How to correct use GDALGCPTransform

Frank Warmerdam warmerdam at pobox.com
Wed Jul 25 09:46:04 EDT 2007


Ivan Mjartan wrote:
> I thing that I am wrong using GCPTransformer I thing that I have to set 
> something in GDALWarpOptions but what? This is for me big mystery. I was 
> looking on internet but there is nothing L
> 
> Can I see some sample of using GCPTransformer ?
> 
> May be I can use GenImgProjTransformer but I don't know how to set GCPs 
> with out prior transform to Gtiff set GCPs and saving to Disk. (Input 
> rasters can be jpg bitmap .)

Ivan,

I believe your problem is that the warper needs a transformer that goes
from input pixel/line coordinates to destination pixel/line coordinates (and
the reverse).  But the GDALGCPTransformer only does source pixel/line to
source georeferenced coordinates.  If you look at GenImgProjTransform() in
gdal/alg/gdaltransformer.cpp you may note it actually performs several steps.
One from source pixel/line to source georef.  Then potentially reproject
to destination pixel/line.  Then dest georef to dest pixel/line.

You could implement your own similar transformer somewhat similar to
GDALGenImgProjTransform, but I think the easier way is just to associate
the GCPs with the source image.  If it is impractical to write the image
to a new TIFF file with gdal_translate, and with the GCPs associated, then
another approach without intermediate files would be to create an in-memory
VRT dataset using GDALCreateCopy() from the source image, and then call
SetGCPs() on that VRT dataset.

Then use the VRT as an input with the GenImgProj transformer.

BTW, to avoid having a VRT written to disk, just use the filename "" for
it when calling CreateCopy().

BTW, the way you included your code (tab expansion, extra blank lines)
made it nearly unreadable.

Good work on all you have already learned about the warper!

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 OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list