[Gdal-dev] How to get the affine information

Frank Warmerdam warmerdam at pobox.com
Mon Oct 1 00:59:22 EDT 2007


On 9/30/07, 沈金祥 <shenjinx at 126.com> wrote:
> Hello ,everyone:
>      It is my first time here,and i am very happy to share all kinds of
> information here! I am a gdal newer ,now i have a problem need your help.
>     I have an image and it format is erdas image(.img),when i open it with
> erdas,i can see the image information as follow:
>
>        upper Left X:565946.1197      upper Left Y:4439207.688
>        Lower Left X:351363.3907      upper Left Y:3363647.278
>        pixel sizeX:N/A               pixel Size Y:N/A
>        unit:meters                  Geo model:Affine
>     Now ,i want to get it affine parameters with gdal function
> GetGeotransform with python,but this image haven't such function. i use the
> Open Function open the image ,and dir()function to view its function ,but i
> just looked the following information:
>
> >>> da=gdal.Open("d:\input\aa.img")
> >>> dir(da)
> ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__',
> '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
> '__setattr__', '__str__']
>
> On the other hand,i try another image with the same course,the result as
> following:
>
> >>> da=gdal.Open("d:\output\yy.img")
> >>> dir(da)
> ['AddBand', 'AdviseRead', 'BuildOverviews', 'FlushCache', 'GetDescription',
> 'GetDriver', 'GetGCPCount', 'GetGCPProjection', 'GetGCPs',
> 'GetGeoTransform', 'GetMetadata', 'GetProjection', 'GetProjectionRef',
> 'GetRasterBand', 'GetSubDatasets', 'RasterCount', 'RasterXSize',
> 'RasterYSize', 'ReadAsArray', 'ReadRaster', 'RefreshBandInfo',
> 'SetDescription', 'SetGCPs', 'SetGeoTransform', 'SetMetadata',
> 'SetProjection', 'WriteRaster', '__del__', '__doc__', '__init__',
> '__module__', '_band', '_o']
>
> I am so wonder what the matter of this,and if one of you ever met such
> problem or known it ,can you tell me in detailed, and i am very grateful!
>      Thank you for your attention!

Jinxiang Shen,

I believe the gdal.Open() on aa.img failed and returned None.
The dir() results look like the results for a None object.

There should have been some sort of error message written
to stderr during the gdal.Open() call.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the Gdal-dev mailing list