“ qgis:heatmapkerneldensityestimation”中的输出参数不起作用

时间:2019-08-16 10:50:58

标签: python qgis

这是代码:

import processing
import os
#defines the folder
folder="C:/Users/Pueyo/Google Drive/Consultoria/Mapa escolar/Dades UMAT/heatmap"
#capts all the files in the folder
filelist=os.listdir(folder)
feedback = QgsProcessingFeedback()
#if the file is a shapefile, run the algortihm
for file in filelist:
    if file.endswith('.shp'):
        layer=QgsVectorLayer(folder+file,file,'ogr')
        file2 = file.replace(".shp",""
        output=str(folder + "/hm200_" + file2 + ".tif")
        parameters={'INPUT':layer,'RADIUS':200, 'PIXEL_SIZE':5,'OUTPUT':output}
        processing.runAndLoadResults('qgis:heatmapkerneldensityestimation', parameters, feedback=feedback)

一个屏幕截图:

https://i.stack.imgur.com/2vLxn.png

这是我得到的错误:

Traceback (most recent call last):
  File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 15, in <module>
  File "C:/PROGRA~1/QGIS3~1.4/apps/qgis- 
  ltr/./python/plugins\processing\tools\general.py", line 138, in runAndLoadResults
        return Processing.runAlgorithm(alg, parameters=parameters, onFinish=handleAlgorithmResults, feedback=feedback, context=context)
  File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 183, in runAlgorithm      raise QgsProcessingException(msg)
_core.QgsProcessingException: There were errors executing the algorithm.

问题一定是输出字符串的定义,因为我尝试了相同的代码,但是直接在参数列表上写了一条路由,并且有效。

0 个答案:

没有答案