[Qgis-developer] QgsMapLayerRegistry.mapLayers() not available
in Python Bindings
Düster Horst
Horst.Duester at bd.so.ch
Fri Jan 11 06:51:53 EST 2008
Barry,
Yep that's exactly the solution for my problem. Thank you very much.
Regards
Horst
------------------------------------------------
Dr. Horst Düster
GIS-Koordinator, Stv. Amtschef
Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
SO!GIS Koordination
Rötistrasse 4
CH-4501 Solothurn
Telefon ++41(0)32 627 25 32
Telefax ++41(0)32 627 22 14
mailto:horst.duester at bd.so.ch
http://www.agi.so.ch
-----Ursprüngliche Nachricht-----
Von: Barry Rowlingson [mailto:b.rowlingson at lancaster.ac.uk]
Gesendet am: Freitag, 11. Januar 2008 11:40
An: Düster Horst
Cc: qgis-developer
Betreff: Re: [Qgis-developer] QgsMapLayerRegistry.mapLayers() not
available in Python Bindings
Düster Horst wrote:
> With Python I want to get all avalilable map layers from my current
> project. I tried to do this with
>
> layerCollection = QgsMapLayerRegistry().instance().mapLayers()
>
> It doesn't work. I took a look into qgsmaplayerregistry.sip and found
> out that the method mapLayers() is not wrapped until now. What is to
do
> to wrap this method. Does exists a workareound to retrieve all project
> layers.
You can get all the layers in the current map canvas from the console
thus:
# get the map canvas
mc=iface.getMapCanvas()
# how many layers are there?
nLayers=mc.layerCount()
# loopage:
for l in range(nLayers):
layer = mc.getZpos(l)
doSomethingWith(layer)
- is that good enough?
Barry
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.qgis.org
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20080111/02e38f3a/attachment.html
More information about the Qgis-developer
mailing list