[gdal-dev] GCPs in MEM driver, can we?

Joaquim Luis jluis at ualg.pt
Sun Dec 7 15:30:17 EST 2008


I have my gdalwarp MEX that works reasonably into converting between projection systems.
And now I would like to have it working to do warping with GPS, but after hours of struggling
with it, I don't advance a bit. The GCPs are alway ignored.

I do create the GCPs like this

	pasGCPs = (GDAL_GCP *) CPLRealloc( pasGCPs, sizeof(GDAL_GCP) * nGCPCount );
	GDALInitGCPs( 1, pasGCPs + nGCPCount - 1 );
	for (i = 0; i < nGCPCount; i++) {
		pasGCPs[i].dfGCPPixel = ptr_d[i];		
		pasGCPs[i].dfGCPLine = ptr_d[i+nGCPCount];
		pasGCPs[i].dfGCPX = ptr_d[i+2*nGCPCount];
		pasGCPs[i].dfGCPY = ptr_d[i+3*nGCPCount];
		pasGCPs[i].dfGCPZ = 0;

Than I set them

	GDALSetGCPs( hSrcDS, nGCPCount, pasGCPs, "" )

and create a transformer

	hTransformArg =
     		GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT,
						 nGCPCount == 0 ? FALSE : TRUE, 0, 1 );

but this bloody thing always returns me what I set in

	eErr = GDALSuggestedWarpOutput2( hSrcDS, GDALGenImgProjTransform, hTransformArg,
                                 adfDstGeoTransform, &nPixels, &nLines, adfExtent, 0 );

and the warping fails (the output is equal to input)

Is this a MEM driver issue, or an error of mine?


Joaquim Luis

More information about the gdal-dev mailing list