0

I have two layers in my project

  1. Point Layer
  2. Building Layer

I recently created Voronoi Polygon on Point Layer say (vor-points layer) But as soon this Happen, the newly created vor-points layer appears on the top of Layer Panel List.

How should i make sure that my Layers (by uploading or newly created ones ) always appear in top to down order and my canvas should show all the layers simultaneously ?

closed as off-topic by ahmadhanb, Vince, Jochen Schwarze, ThingumaBob, whyzar Sep 4 '18 at 13:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – ahmadhanb, Vince, whyzar
If this question can be reworded to fit the rules in the help center, please edit the question.

1

This is a sample code for add on bottom the new layer automatically when new layer is loaded in a QGIS Project

def OrderLayerToBottom(layers):
    lyr = [tree_layer.layer() for tree_layer in QgsProject.instance().layerTreeRoot().findLayers()]
    lyrcnt=len(lyr)
    root = QgsProject.instance().layerTreeRoot()
    myalayer = root.findLayer(layers[0].id())
    myClone = myalayer.clone()
    parent = myalayer.parent()
    parent.insertChildNode(lyrcnt+1, myClone)
    parent.removeChildNode(myalayer)


 QgsProject.instance().legendLayersAdded.connect(OrderLayerToBottom)

Not the answer you're looking for? Browse other questions tagged or ask your own question.