My code in the standalone program
import sys
sys.path.append("C:/OSGeo4W64/apps/qgis-ltr/python/plugins")
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import processing
from processing.core.Processing import Processing
QgsApplication.setPrefixPath("C:/OSGeo4W64/apps/qgis-ltr", True)
qgs = QgsApplication([], True)
qgs.initQgis()
Processing.initialize()
Processing.updateAlgsList()
# Here on
shp1 = QgsVectorLayer("C:/Users/Documents/shape.shp", "shp1", "ogr")
processing.runalg('qgis:fieldcalculator', shp1, "new_field", 0, 1, 2, True, "$Area", "C:/Users/Documents/shape2.shp")
qgs.exitQgis()
The exact same code after the label # Here on
above works when using the Python console within QGIS. Whereas for the standalone program I get the field names but no values. I'm using version 2.18.17. Is this a bug with the software or am I doing something wrong?
Bug report submitted at: https://issues.qgis.org/issues/18395
qgis:advancedpythonfieldcalculator
. You should consider submitting a bug report :)