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

2010-07-22 Thread Python Gis
...@environment.gov.au To: Python Gis pygis2...@yahoo.com Cc: gdal-dev@lists.osgeo.org Sent: Thu, July 22, 2010 1:21:23 AM Subject: RE: [gdal-dev] python bindings: strange behavior with layer The datasource ds is still going out of scope as it is local to your getLayer2 function. Lots of ways to avoid this. Try

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

2010-07-21 Thread Python Gis
drv_shp and shp_ds are going out of scope.  Use ogr.Open, which will take care of all of this for you. Thanks Howard I am using now ogr.Open but there is still the same problem. Looks like I need to reopen the layer in each method, as far as it seems it cannot exist the layer without its

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

2010-07-21 Thread Pinner, Luke
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 =

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

2010-07-20 Thread Howard Butler
On Jul 20, 2010, at 12:51 PM, Python Gis wrote: Hi this is my code: from osgeo import ogr def OpenLayer(shape_path, shape_name): drv_shp = ogr.GetDriverByName('ESRI Shapefile') shp_ds = drv_shp.Open(shape_path, 1) layer = shp_ds.GetLayerByName(shape_name) print 'Name from

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

2010-07-20 Thread Francis Markham
Is there an FAQ somewhere we can put this? It bit me when I was starting with GDAL and Python too. Cheers, Francis On 21 July 2010 04:00, Howard Butler hobu@gmail.com wrote: On Jul 20, 2010, at 12:51 PM, Python Gis wrote: Hi this is my code: from osgeo import ogr def