I´m trying to do some geoprocessing using the QGIS Sextante plugin outside of the QGIS application (and integrate it with different other libraries like arcpy, etc.).
import sys, os
from PyQt4.QtGui import QApplication
QApplication(sys.argv)
from qgis.core import *
import qgis.utils
sys.path.append("C:/Users/.../.qgis/python/plugins")
import sextante
sextante.core.Sextante.Sextante.initialize()
input = "D:/Python_Test/a.shp"
output = "D:/Python_Test/b.shp"
sextante.runalg("qgis:convexhull",input,None,None,output)
print "Finished!"
Unfortunately the process fails with the following error:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:/Users/.../.qgis/python/plugins\sextante\core\Sextante.py", line 376, in runalg
alg = Sextante.runAlgorithm(algOrName, None, *args)
File "C:/Users/.../.qgis/python/plugins\sextante\core\Sextante.py", line 276, in runAlgorithm
if not param.setValue(args[i]):
File "C:/Users/.../.qgis/python/plugins\sextante\parameters\ParameterVector.py", line 59, in setValue
layers = QGisLayers.getVectorLayers(self.shapetype)
File "C:/Users/.../.qgis/python/plugins\sextante\core\QGisLayers.py", line 79, in getVectorLayers
layers = QGisLayers.iface.legendInterface().layers()
AttributeError: 'NoneType' object has no attribute 'legendInterface'
What am I doing wrong? Sextante seems to be initialized correctly because
sextante.alghelp("qgis:convexhull")
gives me
ALGORITHM: Convex hull
INPUT <ParameterVector>
FIELD <ParameterTableField from INPUT>
METHOD <ParameterSelection>
OUTPUT <OutputVector>
I´m using Windows 7 Professional 64Bit and the OsGeo4W installation with QGIS 1.8.0 and python 2.7.4.