Monday, 6 February 2017

Select feature one by one not working in pyQGIS?



I have used following code for selecting the features one by one. but when i run the script it is just selecting last feature and zoom it. I want to select each feature and zoom it.


def SelectFeatures(self):
layer = self.iface.activeLayer();
iter = layer.getFeatures();
for feature in iter:
geom = feature.geometry()
self.iface.mapCanvas().setSelectionColor(QColor("yellow"));
layer.setSelectedFeatures([feature.id()])
selected_features = layer.selectedFeatures()
self.iface.mapCanvas().zoomToSelected( layer )

self.iface.mapCanvas().refresh()


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...