import sys
sys.path.append("c:\\osgeo4w64\\app\qgis\\pyto\\plugins")
import processing, os,glob
layer1 = QgsVectorLayer(layer1ShpFilePath, "layer1", "ogr")
layer2 = QgsVectorLayer(layer2ShpFilePath, "layer2", "ogr")
params = {
'INPUT': layer1,
'OVERLAY': layer2,
'OUTPUT': "TEST.shp"
}
intersectLayer = processing.run("saga:intersect", params)我想用pyQgis来找出两个矢量层之间的相交多边形,但我总是遇到错误AttributeError:模块'processing‘没有属性'run’谁能帮我?我正在window机器上使用QGis编写python,我已经将基本的QGIS路径添加到环境变量中,但我不确定是否需要将SAGA包添加到窗口环境变量中。
发布于 2021-06-14 05:02:02
我也有同样的问题--可能是因为你在sys.path.append中的导入路径不正确(我在你的帖子里看到了一个拼写错误)。
To check your installation you can type sys.path in qgis console:
Python Console
Use iface to access QGIS API interface or Type help(iface) for more info
Security warning: typing commands from an untrusted source can harm your computer
import sys
sys.path
['/usr/share/qgis/python', '/home/<username>/.local/share/QGIS/QGIS3/profiles/default/python', '/home/<username>/.local/share/QGIS/QGIS3/profiles/default/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib64/python39.zip', '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', '/home/<username>/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/site-packages', '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages', '/home/<username>/.local/share/QGIS/QGIS3/profiles/default/python']万事如意,
https://stackoverflow.com/questions/66690762
复制相似问题