[gdal-dev] get back a layer objet with ogr in python

Ludovic Granjon ludovic.granjon at u-bourgogne.fr
Thu Aug 5 03:23:08 EDT 2010


Hello

I'm trying to develop with ogr in python. I'm on ubuntu 10.4 and I use 
gdal 1.7
When I try to get back a layer object from a function, I have the 
following message when I do python monscript.py :
"Erreur de segmentation"

This is my code :

-----------------------
# import modules
from osgeo import ogr

def openShapeLine(shapefile):
     #Ouverture du shapefile avec ogr
     driver = ogr.GetDriverByName("ESRI Shapefile")
     datasource = driver.Open(shapefile)
     layer = datasource.GetLayer()
     return (layer)

couche = openShapeLine('/data/axe.shp')

print couche.GetName()
------------------------

If I do a "print layer.GetName()" inside the openShapeLine function, 
there's no problem ...

Have you any idea ?

Thanks all
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ludovic_granjon.vcf
Type: text/x-vcard
Size: 149 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100805/8edfa951/ludovic_granjon.vcf


More information about the gdal-dev mailing list