How can I get a feature's geometry from selection by attribute.
For instance from a point layer I want to get the geometry by the field CODICE filter (CODICE = A001).
I tried with:
layer = QgsMapLayerRegistry.instance().mapLayersByName("My_layer")[0] selection = layer.getFeatures(QgsFeatureRequest(QgsExpression("\"CODICE\" = 'A001'"))) geom = selection.geometry() It doesn't work, and the python console error is:
AttributeError: 'QgsFeatureIterator' object has no attribute 'geometry'
Thanks
أكثر...
For instance from a point layer I want to get the geometry by the field CODICE filter (CODICE = A001).
I tried with:
layer = QgsMapLayerRegistry.instance().mapLayersByName("My_layer")[0] selection = layer.getFeatures(QgsFeatureRequest(QgsExpression("\"CODICE\" = 'A001'"))) geom = selection.geometry() It doesn't work, and the python console error is:
AttributeError: 'QgsFeatureIterator' object has no attribute 'geometry'
Thanks
أكثر...