Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

from my Plugin I've loaded a rasterlayer using the following code:

fileName = "/path/to/raster/file.tif"
fileInfo = QFileInfo(fileName)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(fileName, baseName)
if rlayer.isValid():
    QgsMapLayerRegistry.instance().addMapLayer(rlayer)
    ...

Now I wonder how I can move the freshly loaded layer to the back, that it lies behind all previously loaded layers.

Thanks and regards

share|improve this question

1 Answer 1

i have not come across to change layer order for taking an instance to back of all layers. But i think you can use addTopLevelItems(items) function for getting all layers to top without your current layer. Maybe it is a reverse solution but i hope it works for your needs.

PySide.QtGui.QTreeWidget.addTopLevelItems(items)

Parameters: items – PySide.QtGui.QTreeWidgetItem
Appends the items  as a top-level item in the widget.

Selecting current layer,

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

Or all layers,

allLayers = canvas.layers()
for i in allLayers: print i

i hope it helps you....

share|improve this answer

Your Answer

 
discard

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.