Quick way to select by attribute and zoom to selection in QGIS

المشرف العام

Administrator
طاقم الإدارة
I need to visually control hundreds of points in a layer on top of aerial photographs. Using the attribute table, selecting (with column filter expression) and zooming manually is cumbersome - so I plugged together a processing script which has the layer and the field, in which I'd like to search, hardcoded to the script..

That script helps - however, It would be much more handy to have a dockwidget in which I could put the search strings, without having to open the algorithm dialog each time I want to search a feature..

Can I put this script to a dockable widget without making a plugin?

Or maybe there are other methods (maybe built in or by available plugins) to quickly search values repeatedly in a field of a layer?

Another idea would be to assign a shortcut to the processing script and thus save me from having to start the algorithm by clicking it in the processing toolbox - but I don't know if this is possible..

from PyQt4.QtCore import * from qgis.core import * from qgis.utils import * #==================================== ##[User scripts]=group ##input_str=string #==================================== canvas = iface.mapCanvas() allLayers = canvas.layers() n = len(allLayers) for i in range(0, n): if allLayers.name() == 'waypoints': break tarL = allLayers # Get a featureIterator from an expression: expr = QgsExpression( "\"name\"='" + input_str + "'" ) it = tarL.getFeatures( QgsFeatureRequest( expr ) ) # Build a list of feature Ids from the result obtained above ids = [j.id() for j in it] # Select features with the ids obtained tarL.setSelectedFeatures( ids ) # Zoom to selected features: canvas.zoomToSelected()

أكثر...
 
أعلى