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

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():

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

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.


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


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.