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

G. Allegri giohappy at gmail.com
Thu Oct 16 12:39:57 PDT 2014


Great Salvatore, you're right.
I thought the geometry wasn't passed by the iterator but it could be used
during  the request expression evaulation. That was wrong ;)

giovanni


2014-10-16 20:44 GMT+02:00 Salvatore Larosa <lrssvtml at gmail.com>:

> 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
>



-- 
Giovanni Allegri
http://about.me/giovanniallegri
Twitter: https://twitter.com/_giohappy_
blog: http://blog.spaziogis.it
GEO+ geomatica in Italia http://bit.ly/GEOplus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141016/98f070fa/attachment.html>


More information about the Qgis-developer mailing list