I'm using QGIS 3.0 model processor. I am trying to control the order in which the outputs render. Any ideas? I have tried to use parent algorithms but it seems to not make a difference. Is this a bug or an incorrect use of the parent algorithm function. Pictured are the outputs from my model. I want to have all the "A" files automatically draw on top of the others when the output from the model. enter image description here]

I've started trying to work with the code given by Kadir below and integrating it into the below hyperlink he provided. I have able to load in and work the example code. Now I am working on integrating Kadir's code into the model. I've included a snippet of the model below as well. https://anitagraser.com/2018/03/25/processing-script-template-for-qgis3/

enter image description here


To move layers whose name start with "A" to top of the layer tree, use that code.

root = QgsProject.instance().layerTreeRoot()
for layer in root.children():
    # you can change the condition
    if layer.name().startswith("A"):
        _layer = layer.clone()
        root.insertChildNode(0, _layer)

If you mean to order features in a layer, use "Order by Expression". To order features by area, use that: (smaller polygons stay behind)

enter image description here

  • So I tried the expression $area, but all my features are points and lines and therefore don't really have an "area." Is there a different expression I can give them? – Mary Johnson Apr 5 '18 at 15:20
  • 1
    Do you want to control the order of layers or the order of features within one layer? – Kadir Şahbaz Apr 5 '18 at 15:25
  • I realized I was not being clear and I got pulled away before I edited my comment. Yes Kadir want to control the order of the layers. I am editing my post now. – Mary Johnson Apr 5 '18 at 15:31
  • Kadir, do I incorporate this into the model by saving it as a script and adding it into my model? Does it matter which output it points to? – Mary Johnson Apr 5 '18 at 16:50
  • 1
    Processing for QGIS 3 refer to Processing script template for QGIS3 – Kadir Şahbaz Apr 5 '18 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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