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

Even Rouault even.rouault at mines-paris.org
Sun Dec 7 16:50:51 EST 2008


Le Sunday 07 December 2008 21:30:17 Joaquim Luis, vous avez écrit :
> Hi,
>
> 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, "" )

Why don't you pass pszSrcWKT instead of "" ? But I'm not sure that it's really 
your issue as you specify it below.

>
> and create a transformer
>
> 	hTransformArg =
>      		GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT,
> 						 nGCPCount == 0 ? FALSE : TRUE, 0, 1 );
>

I think your way of creating hTransformArg is correct when being used by  
GDALSuggestedWarpOutput2, but when doing the really warp, you should pass 
hDstDS instead of NULL as the third argument. See apps/gdalwarp.cpp

> 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?

I think the MEM driver should work. 

>
> Thanks
>
> Joaquim Luis
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list