I am writing a model that takes a polygon shapefile as input, converts it to polylines, explodes it to individual lines and finally applies a (tested) style, khLineLength1.qml, which labels each line with its length.
Here is the log:
Algorithm Polygon_Sides starting...
Prepare algorithm: QGISPOLYGONSTOLINES_1
Running Polygons to lines [1/3]
Parameters: INPUT =C:/Users/DAZ/QGIS_maps/Kaihu/epsg3706/routes_PG.shp
Converting outputs
OK. Execution took 0.187 ms (1 outputs).
Prepare algorithm: QGISEXPLODELINES_1
Running Explode lines [2/3]
Parameters: INPUT =C:\Users\DAZ\AppData\Local\Temp\processing\98fbdd36b519415f9e9bc25e9939916d\OUTPUT.shp
Converting outputs
OK. Execution took 0.234 ms (1 outputs).
Prepare algorithm: QGISSETSTYLEFORVECTORLAYER_1
Running Set style for vector layer [3/3]
Parameters: INPUT =C:\Users\DAZ\AppData\Local\Temp\processing\140dc16954394bd58455470538e300e9\OUTPUT.shp, STYLE =khLineLength1.qml
Converting outputs
OK. Execution took 0.123 ms (1 outputs).
Model processed ok. Executed 3 algorithms total
Converting outputs
Loading resulting layers
Algorithm Polygon_Sides finished
According to this https://docs.qgis.org/2.6/en/docs/user_manual/processing_algs/qgis/vector_general_tools/setstyleforvectorlayer.html the Set style for vector layer algorithm should have a definable output Styled layer. The modeling dialog is allowing me to define the parameters Vector layer and Style file but that is all.
To clarify: In the modeler, for example, when I edit the Explode lines algorithm, I see a title Output layer and beneath it a box with the hint [Enter name if this is a final result]. I do not see this for the styling algorithm and this seems to 'dead-end' the event sequence, preventing rendering and disallowing further styling and the successful execution of any subsequent algorithm.
This is a 'first experience' with the Modeler. Apart from 'little grey cells', what am I missing here?
Answer
I don't think the docs are very clear on this. From my understanding, the Set style for vector layer algorithm does not create a new output layer. The end result is the input layer with the style file applied. I believe this is why there is no "output" option for the algorithm.
From the QGIS 2.8 docs and checking the parameters from the Python console, both mention an Output
:
import processing
processing.alghelp("qgis:setstyleforvectorlayer")
ALGORITHM: Set style for vector layer
INPUT
STYLE
OUTPUT
However, when you check the Console usage, you will see that there is no parameter for Output
:
processing.runalg("qgis:setstyleforvectorlayer", input, style)
So if you want to add more than one style to a shapefile, you may need to create another set of the same algorithms within your model.
Hope this helps!
No comments:
Post a Comment