[Qgis-developer] select a loaded raster layer from qgis legend into python plugin

2013-01-17 Thread Otto Dassau
Hi, I would like to write a small python plugin to analyse some raster data, but I haven't managed to select a loaded layer yet. I searched the howtos and found several simple examples about: # get the currently active layer layer = self.iface.mapCanvas().currentLayer() but as I said I would

Re: [Qgis-developer] select a loaded raster layer from qgis legend into python plugin

2013-01-17 Thread Matthias Kuhn
Hi Otto, here a small extract from a plugin I wrote: Just check for the layer type to only list raster layers def initLayerCombobox(self,combobox, default): reg = QgsMapLayerRegistry.instance() for ( key, layer ) in reg.mapLayers().iteritems(): combobox.addItem(

Re: [Qgis-developer] select a loaded raster layer from qgis legend into python plugin

2013-01-17 Thread Otto Dassau
Hi Matthias, thanks for your help. I guess it is similar to what I found? def getRasterLayersNames(): layerList = [] layerMap = QgsMapLayerRegistry.instance().mapLayers() for name, layer in layerMap.iteritems(): if layer.type() == QgsMapLayer.RasterLayer

Re: [Qgis-developer] select a loaded raster layer from qgis legend into python plugin

2013-01-17 Thread Matthias Kuhn
Hi Otto, Try this class MyPluginDialog (QDialog,Ui_MyPluginDialog):: def __init__(self): self.setupUi(self) self.initLayerCombobox( self.ui.InRastA, 'key_of_default_layer' ) def initLayerCombobox(self,combobox, default): combobox.clear() reg =

Re: [Qgis-developer] select a loaded raster layer from qgis legend into python plugin

2013-01-17 Thread Otto Dassau
Hi Matthias, that works. Thanks a lot! Regards Otto Am Thu, 17 Jan 2013 17:24:43 +0100 schrieb Matthias Kuhn matthias.k...@gmx.ch: Hi Otto, Try this class MyPluginDialog (QDialog,Ui_MyPluginDialog):: def __init__(self): self.setupUi(self)