In a QGIS script, how do you set a Vector input (via your tool's GUI) as a variable which can then be used in subsequent processing in your tool's script?
I know how to set a map Layer as a variable, for example:
pts = QgsMapLayerRegistry.instance().mapLayersByName('civic_pts')[0]
But instead of hard-wiring my file inputs like that, I want the flexibility of setting my inputs via the tool's GUI.
I've tried:
##Input_civic_pts=vector
...and then tried using it later in the script, for example...
for feat in Input_civic_pts.getFeatures():
...but this generates an error.
The same script works fine when I hard-wire the civic_pts file as above.
Obviously I don't know how to convert an Input to a scripting variable.
1 Answer 1
The
##Input_civic_pts=vector
doesn't mean the layer object, you have to use a function to get the layer object itself:
inputLayer = processing.getObject(Input_civic_pts)
See the documentation here: http://docs.qgis.org/2.0/ca/docs/user_manual/processing/console.html