Wednesday, 1 August 2018

qgis - pyqgis: How to get features of selected geometries


I wonder if anybody could provide an example how to get the attributes of selected Features?


I tried the folowing Code in the python Console - but I'm stuck at the point where I'd like to get the attributes:


qgis.utils.iface
canvas = qgis.utils.iface.mapCanvas()
cLayer = canvas.currentLayer()

selectList = []
if cLayer:
count = cLayer.selectedFeatureCount()
print count
selectedList = layer.selectedFeaturesIds()
for f in selectedList:
# This is where I'm stuck
# As I don't know how to get the Attributes of the features

I would be really glad if anybody could help.



Regards




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