[gdal-dev] Help understanding GDALApplyGeoTransform and GDALInvGeoTransform

Even Rouault even.rouault at mines-paris.org
Fri Jul 31 14:20:46 EDT 2009


Bill,

that's weird. Your code looks correct and I've just compiled it and I get the 
following results :

lat-lon -127, 51
7.24754e-13, 4.12115e-13

The new_x, new_y values are almost 0 as expected (the small difference is due 
to numerical imprecision when computing the inverse geotransform).

I can't understand why you get such wrong values.

Le Friday 31 July 2009 19:56:39 Cassanova, Bill, vous avez écrit :
> double adfGeoTransform[6] = { -127, .011571482, 0, 51, 0, -.008993 };
>
> double adfReverseGeoTransform[6] = { 0, 0, 0, 0, 0, 0 };
>
> GDALInvGeoTransform( adfGeoTransform, adfReverseGeoTransform );
>
> double dfPixel = 0;
> double dfLine = 0;
> double x;
> double y;
>
> GDALApplyGeoTransform(   adfGeoTransform, dfPixel, dfLine, &x, &y );
>
> std::cout << "lat-lon " << x << ", " << y << std::endl;
>
> double new_x;
> double new_y;
>
> GDALApplyGeoTransform(   adfReverseGeoTransform, x, y, &new_x, &new_y );
>
> std::cout << new_x << ", " << new_y << std::endl;




More information about the gdal-dev mailing list