I'm looking for some Python + QGIS for the following:
import processing
for i in range (1,20):
processing.runalg("qgis:zonalstatistics", "/folder/input/raster.tif",%i,
"/folder/input/poly.shp","Var_%i",True, "/folder/output/zonalpoly_%i.shp"
The above BASH like example doesn't work, but if I substitute an integer in place of %i, the script runs correctly, so I know that the syntax is correct.
I'm a bit fuzzy on how to properly pass a variable into a string using Python and/or how to run a QGIS plugin from the built-in Python interpreter for QGIS.
Also, qgis:zonalstatistics calculates several summary statistics (mean, stddev, maximum, etc.) with no apparent means of specifying one or a few of these.
Is there a way of specifying just one, or a few?
It seems like a complete waste of processing time to calculate each if I'm only interested in one or a few measures.
TypeError: unsupported operand type(s) for %: 'dict' and 'int'– Prophet60091 Apr 05 '14 at 00:32"Var_{}". Should be"Var_{0}"in the first example. Example 1 definitely works. Let me know if you can figure out the issue for Example 2. – Prophet60091 Apr 05 '14 at 00:54Var_{0}in Python 2.6,Var_{}in Python 2.7 – gene Apr 06 '14 at 19:56