[gdal-dev] Using GCP Transformer
Matt Hanson
mhanson at photon.com
Wed Apr 22 11:27:47 EDT 2009
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/20090422/792cecb6/attachment.html
More information about the gdal-dev
mailing list