Friday, 3 January 2020

pyqgis - QGIS Filter layer by expression




Can I make the filter by the value that is obtained by the function?


for feature in iter:
name_dot = feature['name']
print name_dot
expr = QgsExpression("\"name\"=name_dot")
selection= layer.getFeatures(QgsFeatureRequest(expr))
ids = [s.id() for s in selection]
layer.setSelectedFeatures(ids)
iface.mapCanvas().zoomToSelected()


This does not work, and I do not know where the mistake is.




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