[gdal-dev] GDALWarp GCP

Matt Hanson mhanson at photon.com
Fri May 15 13:11:24 EDT 2009


Hello,   I sent the email to the list in April but it's gotten no
response.    I've since scoured the 'net and the GDAL archives, tried
countless number of permutations and every time end up with a blank
image.   I'm obviously missing something, yet the archives and
documentation don't provide any clear explanation of how this may be
accomplished.    Any pointers would be greatly appreciated!
Thanks!
Matt

Wed, 22 Apr 2009 08:28:58 -0700
Hello, 

I'm having trouble getting an image warped  properly using GCPs.   I'm
wondering if I'm missing a piece in my code.

Here  I am warping from an image with a presumably unknown projection to
a georeferenced reference image.   The images have been registered
either manually or automatically and the GCPs come from that -
pixel/line in the unknown image corresponding to georeferenced
coordinates in the reference image.

************************************************************
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();

psWarpOptions->pTransformerArg = GDALCreateGCPTransformer(gdalgcpssize,
gdalgcps, order, 0);
psWarpOptions->pfnTransformer = GDALGCPTransform;
psWarpOptions->eResampleAlg = GRA_NearestNeighbour;

psWarpOptions->hSrcDS = // Set to source image
psWarpOptions->nBandCount = 0; 
psWarpOptions->pfnProgress = GDALTermProgress;   

double adfDstGeoTransform[6];
int nPixels=0, nLines=0;
GDALSuggestedWarpOutput( psWarpOptions->hSrcDS, GDALGCPTransform, 
psWarpOptions->pTransformerArg, adfDstGeoTransform, &nPixels, &nLines
                

// Create new output image of size nPixels x nLines
// Copy Projection info from georeferenced image
psWarpOptions->hDstDS = // Set to new output image

// Initialize and execute the warp operation
GDALWarpOperation oOperation;
oOperation.Initialize( psWarpOptions );
oOperation.ChunkAndWarpImage( 0, 0, nPixels, nLines );
************************************************************

Are these essentially the correct steps to do this?    GDAL runs without
any errors and generates an output image which has the correct
projection info and reasonable looking geographic corner coordinates.
However the resulting image is all black.

Thanks in advance for any clues anyone could provide!

matt


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090515/4f9aa539/attachment.html


More information about the gdal-dev mailing list