[Qgis-developer] QgsFeatureRequest.NoGeometry flag makes iterator return no features

Salvatore Larosa lrssvtml at gmail.com
Thu Oct 16 11:44:41 PDT 2014


Hi Giovanni,

On Thu, Oct 16, 2014 at 7:45 PM, G. Allegri <giohappy at gmail.com> wrote:
> I need to iterate over a layer without the need of geometries.
> I rembember I used this flag time ago and it worked fine. Now, if I set this
> on the feature request, I get an empty set of features from the iterator. Am
> I doing something wrong?
>
> req = QgsFeatureRequest(QgsExpression('$area>1000,00'))
> reg.setFlags(QgsFeatureRequest.NoGeometry)
> feats = [f for f in mylayer.getFeatures(req)]

if you set flag to NoGeometry you cannot pass the $area function as it
needs of the geometry in order to calculate the correct value.
your snippet should to work whether you store the value of $area in a
new field and use it in your espression

Could this be a reason? :)

Ciao.

-- 
Salvatore Larosa
linkedIn: http://linkedin.com/in/larosasalvatore
twitter: @lrssvt
skype: s.larosa
IRC: lrssvt on freenode


More information about the Qgis-developer mailing list