[gdal-dev] python: possible to get Dataset from Band

Gregory, Matthew matt.gregory at oregonstate.edu
Tue Nov 9 18:56:21 EST 2010


Even Rouault wrote:
> Le mercredi 10 novembre 2010 00:10:08, Paolo Corti a écrit :
> > Do we really need this? As far as I remember band must be in the same
> > context of dataset (dataset can't go out of scope), so why would we
> > need a reference to it?
> 
> You're 100% right. By the way, assigning the dataset as a member of the
> band is an excellent means of making sure that we keep a reference to
> the dataset.
> That's indeed the gist of the patch attached to ticket
> http://trac.osgeo.org/gdal/ticket/3592 .

Forgive my likely stupidity, but I was trying to use the reference to the gdal.Dataset in this way:

def silly_reference_ds(rb):
    return rb.ds.GetGeoTransform()

ds = gdal.Open('L:/orcawa/spatial/topography/dem30')
rb = ds.GetRasterBand(1)
rb.ds = ds
print silly_reference_ds(rb)

such that I could pass around Bands instead of Datasets (and band numbers) to functions, but still have reference to things like the geotransform.  Am I way off base?

thanks, matt




More information about the gdal-dev mailing list