2

I have a complex workflow prepared in the processing modeler, but I'm missing one step to link all the model.

I need to dissolve a polyline vector in a single line vector that has as attribute the SUM of a specified attribute of the polyline vector. I can do it via plugin (dissolve with stats) but just outside the modeler, I tried to find a way to link the "dissolve" tool and the "basic statistics for numeric field" tool but I still can't figure out how to put the html output inside the vector layer.

I saw some comments about an sql query that looks easy, but I don't know if I can use it outside spatialite or sql, inside the modeller.

I tried the command SELECT SUM(column_name) FROM table_name;

but as out put i got GDAL command output: FAILURE: Unable to open datasource

Is it because the layer has to be inside an sql database to run this kind of query?

2

You can use gdal/ogr tool inside your modelbuilder :

enter image description here

hope that helps

1

Ujaval gandhi from qgistutorials prepared a python script to be run inside the modeler that solves the problem, here is the tutorial that Ujaval made for everyone. http://www.qgistutorials.com/en/docs/processing_python_scripts.html

  • 2
    Yes, brilliant tutorials! You should edit your answer to include the code you linked. Just in case the link is broken, the code will still be available for users =) – Joseph Aug 11 '15 at 10:30
0

You can also use the ogr2ogr based tool "Dissolve polygons" and click on "compute min/max/sum/mean for the following attribute". It executes this query:

ogr2ogr "[temporary file]" folder/file.shp file -dialect sqlite -sql "SELECT ST_Union(geometry),Column FROM 'file' GROUP BY Column"

Available in QGIS >= 2.10

enter image description here

  • This tool works only for polygons. the question is about polylines – Mattia Sep 21 '15 at 7:56
  • 2
    Hi, I'm the author of "dissolve polygons" inside the OGR category in the QGIS Processing toolbox. If you think that a "dissolve lines" tool is handy then please open a feature request on the QGIS bug tracker and assign it to me. Cheers. – Giovanni Manghi Sep 21 '15 at 8:06
  • @GiovanniManghi done: hub.qgis.org/issues/13386 – Mattia Sep 21 '15 at 9:12

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.