[gdal-dev] Layer.GetNextFeature() does not seem to get the next feature (Python 2.7.2, GDAL1.9.2
Even Rouault
even.rouault at mines-paris.org
Thu Dec 20 22:56:04 PST 2012
Le vendredi 21 décembre 2012 05:36:09, David Verbyla a écrit :
> I have a layer of 15 polygons from a shapefile. I can access the features
> using Layer.GetFeature(i),
> but not using Layer.GetNextFeature().
>
> For example:
> >>> polyFeature = pondsLayer.GetFeature(0)
> >>> print polyFeature.GetFID()
>
> 0
>
> >>> polyFeature = pondsLayer.GetFeature(1)
> >>> print polyFeature.GetFID()
>
> 1
>
> >>> polyFeature = pondsLayer.GetFeature(0)
> >>> print polyFeature.GetFID()
>
> 0
>
> >>> polyFeature = pondsLayer.GetNextFeature()
> >>> print polyFeature.GetFID()
>
> Traceback (most recent call last):
> File "<pyshell#23>", line 1, in <module>
> print polyFeature.GetFID()
> AttributeError: 'NoneType' object has no attribute 'GetFID'
>
> Any suggestions?
Note that the feature retrieved by GetNextFeature() isn't influenced by
previous calls to GetFeature(), but just by previous calls to
GetNextFeature(), ResetReading(), SetNextByIndex(), and sometimes
GetFeatureCount().
Perhaps you have installed a spatial and/or attribute filters that would result
in an empty answer ?
>
> Thanks.
>
> Dave Verbyla
More information about the gdal-dev
mailing list