[gdal-dev] python bindings: strange behavior with layer

Pinner, Luke Luke.Pinner at environment.gov.au
Wed Jul 21 19:21:23 EDT 2010


The datasource "ds" is still going out of scope as it is local to your
"getLayer2" function.
Lots of ways to avoid this. Try not wrapping it up in a function, or
return a tuple of datasource and layer e.g.

def getDSandLayer(shape_fullname):
    ds = ogr.Open(shape_fullname, 0)
    layer = ds.GetLayer(0)
    print 'Name from method: %s' % layer.GetName()
    return ds,layer;

ds,layer = getLayer2('output/myshape.shp')
print 'Name from main: %s' % layer.GetName()

Luke


------
If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments. 



Please consider the environment before printing this email.

------



More information about the gdal-dev mailing list