Python 3.X issue
drnextgis opened this issue · 4 comments
drnextgis commented
@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'
drnextgis commented
Workaround:
feat = layer.GetNextFeature()
while feat is not None:
print(feature)
feat = layer.GetNextFeature()
dezhin commented
Does it work with original gdal python bindings?
Denis Rykov <notifications@github.com> 14 ноября 2017 г. 6:20:18 ДП написал:
… @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'
```
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#31
drnextgis commented
Yes, original bindings (located at /usr/lib/python3/dist-packages/osgeo) works as expected.
dezhin commented
This issue has been fixed in pygdal=*.6