nextgis/pygdal

Python 3.X issue

drnextgis opened this issue · 4 comments

@dezhin does pygdal is not compatible with Python 3. I'm trying to iterate overs shapefile features but get an error:

>>> from osgeo import ogr
>>> driver = ogr.GetDriverByName('ESRI Shapefile')
>>> dataSource = driver.Open('united_roads.shp', 0)
>>> layer = dataSource.GetLayer()
>>> for feature in layer:
...   print(feature)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: iter() returned non-iterator of type 'Layer'

Workaround:

feat = layer.GetNextFeature()
while feat is not None:
    print(feature)
    feat = layer.GetNextFeature()

Yes, original bindings (located at /usr/lib/python3/dist-packages/osgeo) works as expected.

This issue has been fixed in pygdal=*.6