5

When I use QGIS Dissolve geoalgorithm as a standalone tool from the Processing Toolbox, the GUI looks like shown below. By selecting the Input layer I am able to chose from its attributes on wich to dissolve.

NOTE that the Input layer is an output of another geoprocessing algorithm, in this case Intersection. This takes two input layers and combines the attributes of them. In the Dissolve algorithm I need to select one (key)attribute of each of this input layers:

enter image description here

Now I would like to combine Intersection and Dissolve in the Graphical Modeler, sth. like

enter image description here

... but I struggle with the configuration of the Dissolve alg. Herein its GUI looks slightly different:

enter image description here

Intuitivly I would guess that the dropdown Unique ID fields should by populated with the attribute names of the selected Input layer in order to select the desired attributes to dissolve on, but it doesn't (wich is clear at a second look, because during creating the model the input attributes are unknown since input layers are not yet selected)

Therefore I tried entering a comma separated list of the attribute names (prior known to me, here id, name), but this is causing an error

Error executing algorithm Dissolve 'NoneType' object has no attribute 'split' See log for more details

enter image description here

...wich usually happens with unchecked Dissolve all and no attributes provided.

Question: How to select the attributes to dissolve on when using Dissolve algorithm in Modeler with another algorithms output as input? Am I missing something or am I using this in an inappropriate way or is this worth raising an issue?

  • 1
    In your modeler, try adding the Table multiple field input parameter and connect it to the Dissolve algorithm. You should be able to select fields when you run the model. – Joseph May 4 '18 at 10:00
  • 1
    This works great when the Input layer for the Dissolve algorithm is one of the models input layers (layers existing prior to model execution) but fails, when the input of the dissolve alg. is the output of another algorithm (in my case its the intersection, which combines the attributes of two input layers). Me thinks I should clarify this in my question... – Jochen Schwarze May 4 '18 at 10:47
3

For my special case, a small processing scripts seems to be needed which takes as input arguments the input layer and the two key fields of the input layers of the above referred Intersection algorithm:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# define interface
##[giswg]=group
##Dissolve post intersection=name
##Intersected_layer=vector
##Key_field_layer1=field Intersected_layer
##Key_field_layer2=field Intersected_layer
##dissolved=output vector

from processing import *

input = processing.getObject(Intersected_layer)
runalg('qgis:dissolve', input, False, [Key_field_layer1, Key_field_layer2], dissolved)

In the model the key attributes of the two Intersection input layers can be defined as model parameters and connected to the Dissolve processing script:

enter image description here

2

You could do it without using scripts. The issue here is that you need to type the field names manually inside the modeler. Just type those dissolve fields separated by commas. Like this:

enter image description here

You are going to find out that, when you enter again into the dissolve tool options, these typed fields are "gone" (Unique ID fields will be blank). Don't worry, they are there and it should work if they were well typed. Give it a try.

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.