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 ?

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)
| improve this answer | |

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