[gdal-dev] Spatial Resolution from img file

Kyle Shannon kyle at pobox.com
Thu Jul 30 07:55:21 PDT 2015

On Thu, Jul 30, 2015 at 5:03 AM, user gdal <userofgdal at gmail.com> wrote:
> Dear friends,
> I have a geo ref. ERDAS img file. How to obtain its spatial resolution
> programmatically (C++)?
> One suggestion I received was to refer to gdalinfo.c However I couldn't get
> the required information in gdalinfo.c. I also felt it to be unclear. What I
> have seen in gdalinfo is how to get columns, rows etc. (for which we needn't
> visit the gdalinfo program).

It's in there, the program prints out:

Pixel Sizes = (dx,-dy)

So it has to have the code.

> I expected something like GetXResolution(..) and GetYResolution(...) kind of
> situation. But...

The information you are looking for is contained in the geotranform
matrix available through

GDALGetGeoTransform(GDALDatasetH, double*);

See the api tutorial for more information:


> Any help, please!
> With thanks,
> Yours sincerely,
> B. Ramesh
> _______________________________________________
> 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