Python Gis
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 not wrappi
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.GetLa
> 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
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 wrote:
>
> On Jul 20, 2010, at 12:51 PM, Python Gis wrote:
>
>> Hi
>> this is my code:
>>
>> from osgeo import ogr
>>
>> def OpenLayer(shape_p
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 '