[Qgis-developer] Select By Attribute

Michael McInnis mmcinnis59 at msn.com
Thu Feb 27 09:41:47 PST 2014


Desperately need help doing attribute based selection :

How do I select all features in a LAYER that the Field LWFLAG != 'P'
Python Console

from osgeo import ogr

canvas = qgis.utils.iface.mapCanvas()

allLayers = canvas.layers()

for i in allLayers: i.selectAll(); print i.name(); print
i.selectedFeatureCount()

 

for i in allLayers: i.selectAll(); print i.name(); print
i.selectedFeatureCount()

i.getFeatures(QgsFeatureRequest().setFilterExpression(‘
“LWFLAGS” != \’P\’) )

 

exp =
QgsExpression(‘LWFLAG <> “P” ’) 


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140227/32667b71/attachment.html>


More information about the Qgis-developer mailing list