QGIS 3 Python遍历图层并运行算法

时间:2019-03-04 12:14:28

标签: python gis qgis

我试图遍历各层并在每层上运行处理算法,但输入出现错误:

代码

feedback = QgsProcessingFeedback()

# Get current layers
layers = QgsProject.instance().mapLayers().values()

# Loop through layer and run algorithm
for layer in layers:
    processing.run("qgis:pointstopath", {'INPUT': layer, 'ORDER_FIELD': 'name', 'GROUP_FIELD': 'name','OUTPUT': layer+'.gpkg'},feedback)

错误

Traceback (most recent call last):
File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 2, in <module>
File "C:/OSGEO4~1/apps/qgis-rel- 
dev/./python/plugins\processing\tools\general.py", line 105, in run
return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback,
context)
File "C:/OSGEO4~1/apps/qgis-rel- 
dev/./python/plugins\processing\core\Processing.py", line 183, in 
runAlgorithm
raise QgsProcessingException(msg)
_core.QgsProcessingException: There were errors executing the algorithm.

您如何正确解析地图中的输入图层到算法?

0 个答案:

没有答案