Hi All,

I found a post a while back regarding GDALApplyGeoTransform and
GDALInvGeoTransform
(http://n2.nabble.com/Converting-raster-pixel-space-to-geospace-td325875
1.html )

GDALApplyGeoTransform() will convert from pixels to georeferenced
positions 
and GDALInvGeoTransform() will invert the geotransform matrix, so using 
GDALApplyGeoTransform() on that inverted matrix will do the reverse 
conversion (georeferenced positions --> pixel positions)


I have written some test code that for some reason is not returning the
correct results:

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;


========================================================================
============
Output

lat-lon -127, 51  This result is correct as I have requested the lat-lon
of the first point.

This result is NOT correct.  I pushed the values -127, and 51 through
the inverse transform.  I would have thought the answer
Would have been 0, 0.  

10975.3, 5671.08

Thanks,
Bill
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to