[QGIS-Developer] Concatenating QgsFeatureRequest
etienne.trimaille at gmail.com
Tue Dec 19 07:44:42 PST 2017
You should have a look to the blog post from Nyall:
So you can still use your `setFilterExpression`
for feature in vector_layer.getFeatures(request):
# do something with the feature
2017-12-19 16:41 GMT+01:00 Matthias Kuhn <matthias at opengis.ch>:
> Hi Matteo,
> No, it's not possible to combine the two in the query itself.
> But sending the request with the filter expression and then checking if
> each feature's id is in selectedFeatureIds() should be straightforward.
> selcted_ids = layer.selectedFeatureIds()
> for feature in layer.getFeatures(request):
> if feature.id() in selected_ids:
> On 12/19/2017 04:33 PM, matteo wrote:
> > Hi devs,
> > maybe the question can sound trivial but I didn't find a solution.
> > Simply I would like to iterate only on selected features of a vector
> > layer features with an expression.
> > I know that the QgsFeatureRequest can be used with `setFilterExpression`
> > and `setFilterFids`.
> > Is it possible to combine them, so merging the following example in an
> > unique request?
> > exp = ''' "PH" > 7 '''
> > request = QgsFeatureRequest().setFilterExpression(exp)
> > l = [i.id() for i in vl.selectedFeatures()]
> > request = QgsFeatureRequest().setFilterFids(l)
> > for i in vl.getFeatures(request):
> > ......
> > Thanks for all the suggestions!
> > Cheers
> > Matteo
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the QGIS-Developer