[gdal-dev] Issue with python bindings.

Ivan Willig iwillig at gmail.com
Tue Oct 26 10:54:24 EDT 2010


Thanks Frank. That seems to be the issue. Whats the rule about this how long
you should keep a reference. For example this causes the same issue.

ds.GetLayer().GetFeature(0).GetGeometryRef().GetEnvelope()

Which I am going to guess is because I should keep a reference to the
geometry. Correct?

Ivan Willig




On Tue, Oct 26, 2010 at 10:44 AM, Frank Warmerdam <warmerdam at pobox.com>wrote:

> Ivan Willig wrote:
>
>> Hi list,
>> I am having an issues with using the python swig based bindings. I am on
>> Fedora 13 using the default gdal rpm, which is at version 1.6.2. My issue is
>> when i stack method calls.  For example when I do the following:
>> ogr.Open("/home/ivan/dev/bigapps/data/nyco.shp").GetLayer().GetFeature(0)
>>
>>
>> I get a Segmentation fault. Here are the results of strace
>> http://paste.pocoo.org/show/281682/. What am I doing wrong? Should I just
>> hand compile a new version of gdal? Or is this not an advised usage of the
>> python bindings? A limitation in swig? Thanks for your help.
>>
>
> Ivan,
>
> I believe the problem is object lifetimes.  Keep a reference to the
> datasource around until you are done with the feature(s).
>
> ds = ogr.Open("/home/ivan/dev/bigapps/data/nyco.shp")
> feat = ds.GetLayer().GetFeature(0)
> ...
> feat = None
> ds = None
>
> Best regards,
> --
>
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20101026/848efcbc/attachment-0001.html


More information about the gdal-dev mailing list