1

i want to run this PYQGIS python script in standalone out of QGIS and i use PyCharm Idle. but my code have error on the file format.

the script

from qgis.core import *
import sys
import qgis.utils
from osgeo import ogr
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.gui import *

# supply path to qgis install location
QgsApplication.setPrefixPath("/usr", True)#for linux

# create a reference to the QgsApplication, setting the
# second argument to False disables the GUI
qgs = QgsApplication([], False)
# load providers
qgs.initQgis()

# Write your code here to load some layers, use processing algorithms, etc.
sys.path.append('/usr/share/qgis/python/plugins')
from processing.core.Processing import Processing
import processing
Processing.initialize()
rasterlyr=QgsRasterLayer('/home/qgis2/PycharmProjects/test/aster.tif')
rasterlyr.isValid()
#slope='/home/qgis2/PycharmProjects/test/slope.tif'
#aspect='/home/qgis2/PycharmProjects/test/aspect.tif'
processing.runalg('saga:slopeaspectcurvature', rasterlyr,6,1,1,'/home/qgis2/PycharmProjects/test/slope.tif','/home/qgis2/PycharmProjects/test/aspect.tif',None,None,None,None,None,None,None,None,None,None)
#processing.alghelp("saga:slopeaspectcurvature")
# When your script is complete, call exitQgis() to remove the provider and
# layer registries from memory
qgs.exitQgis()

error message :

ERROR 4: `/tmp/processing969c81d9be194fa49b8dd2c0daebf68b/f9a3240b743f4554b2602e7940bf8fd2/SLOPE.sdat' not recognised as a supported file format.

*** Error in `/usr/bin/python2.7': corrupted double-linked list: 0x0af99d30 ***
======= Backtrace: =========

backtrace have many linux paths.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.