I am attempting to run my Python script using the Processing Toolbox in QGIS 2.0. I've used the built-in Python function map() and zip() several times and am now receiving a syntax error even though these functions worked fine in python console. Thanks in advance.
*I was asked to post a little more of my code, so i've edited and added a different chunk as I don't run into these errors when loading the vector layers by pathname…This makes me wonder if there's something wrong with the way these layers input into the Processing script. Mahalo:
from qgis.core import * from PyQt4.QtCore import * from PyQt4.QtGui import * from processing.core.VectorWriter import VectorWriter import numpy import processing ##input1=vector ##input2=vector ##Attribut=field input1 ##output=output file indivLayer = processing.getobject(input1) grosLayer = processing.getobject(input2) indivprovider = indivLayer.dataProvider() grosprovider = grosLayer.dataProvider() #Break grosLayer dictionary into list of lists (keys represent names of zones) for key in CG_IDdict.keys(): listofzones = CG_IDdict.values() #Get sum of list of zones and put in dictionary with CG_ID keys sumList = map(sum, listofzones) sumdict = dict(zip(CG_IDlist, sumList) #Count in zone countList = map(len, listofzones) #Get max and min value of zones maxValue = map(max, listofzones) minValue = map(min, listofzones) #Get average value meanValue = map(numpy.mean, listofzones)
Traceback (most recent call last): File "C:\Documents and Settings\user/.qgis2/python/plugins\processing\core\GeoAlgorithm.py", line 150, in execute self.processAlgorithm(progress) File "C:\Documents and Settings\user/.qgis2/python/plugins\processing\script\ScriptAlgorithm.py", line 213, in processAlgorithm exec(script) in ns File "<string>", line 74 countList = map(len, listofzones) ^ SyntaxError: invalid syntax