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'm trying to write a python plugin to create an input file for an urban climate model out of three shape files. One of the shape files contains the buildings (polygon), one the trees (point), and the third one the center point of the new model input file (point).

I therefore need a function to select one layer out of the currently displayed ones. I tried messing around with


but then I get some ugly output like

qgis.core.QgsVectorLayer object at 0xb4b6f5c.

Is there a possibility to get readable names out of this? Or is there an easier way to select the layers?

Any ideas or help greatly appreciated!

share|improve this question
up vote 2 down vote accepted

You're returning the layer itself. Go one step further and return the name (property) of the layer. Like this:

layers = qgis.utils.iface.legendInterface().layers()

for layer in layers:
    layerName =
    print layerName #or do something else with the name
share|improve this answer
Great! That does it. Thanks a lot! – Dominik Froehlich Sep 13 '12 at 10:09
@DominikFroehlich, great! Will you please mark this as the accepted answer, by clicking the checkmark next to the answer? Thanks :-) (why and how: – andytilia Sep 13 '12 at 15:34
Ah, now it worked. I had scripts blocked… My fault… Oo – Dominik Froehlich Sep 18 '12 at 9:07

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.