Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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.


share|improve this question

This will work:

features = layer.selectedFeatures()
for f in features:
    print f.attributeMap()
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.