I'm trying to run the following python script:
from qgis.core import *
import sys
import os
import qgis.utils
from qgis.analysis import *
app = QgsApplication([],True,"")
# supply path to where is your qgis installed
QgsApplication.setPrefixPath("/Applications/QGIS.app/Contents/MacOS/", True)
# load providers
QgsApplication.initQgis()
sys.path.append("/Applications/QGIS.app/Contents/Resources/python/plugins")
import processing
layer3 = QgsVectorLayer("../output/precinctsZipcodes.shp", "intersect", "ogr")
if layer3.isValid():
print "Loaded layer 3"
else:
print "Layer 3 failed to load!"
processing.runalg("qgis:exportaddgeometrycolumns", layer3, 0, "../output/precinctsZipcodesArea.shp")
QgsApplication.exitQgis()
However, the line processing.runalg("qgis:exportaddgeometrycolumns", layer3, 0, "../output/precinctsZipcodesArea.shp") isn't saving any output. The strange thing is that this syntax works when I run it directly in the python console. Does anybody know what might be happening?
processing.runalgwithgeneral.runalg. – Joseph Nov 06 '15 at 10:46general.runalg()is the way I call QGIS processing algorithms from standalone scripts, as you can also see in my answer. – Germán Carrillo Nov 06 '15 at 17:17