[gdal-dev] ngpython and GetSubDataSets()?

Frank Warmerdam warmerdam at pobox.com
Tue Feb 12 16:42:04 EST 2008


Jose Luis Gomez Dans wrote:
> Hi, I've just compiled gdal 1.5.0 on a Linux RHEL5 X86_64 machine. I need to
> use HDF files extensively, so I've been trying to test whether the new
> compiled GDAL works. In python, I noticed that I no longer get all the
> methods I used to get.
...
> AttributeError: GetSubDatasets
> 
> I solved the problem by getting rid of the
> /usr/lib64/python2.4/site-packages/GDAL-1.5.0-py2.4-linux-x86_64.egg/
> directory, which takes me back to the "oldgen" bindings. My question is
> whether all the methods from the oldgen bindings have already made it to the
> ng bindings, or whether there will be other changes that will make my
> software incompatible when the ng switch goes live, and for which I will
> need to modify my code.

Jose,

I see this was implemented in the old gen bindings as a convenience
function like this:

     def GetSubDatasets(self):
         sd_list = []

         sd = self.GetMetadata('SUBDATASETS')
         if sd is None:
             return sd_list

         i = 1
         while sd.has_key('SUBDATASET_'+str(i)+'_NAME'):
             sd_list.append( ( sd['SUBDATASET_'+str(i)+'_NAME'],
                               sd['SUBDATASET_'+str(i)+'_DESC'] ) )
             i = i + 1
         return sd_list

You could essentially do the same thing in your own code.

Howard, how would you feel about incorporating this as syntactic
sugar in the NG bindings?

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    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list