【发布时间】:2020-11-06 08:01:17
【问题描述】:
我有一个基于光栅层的矢量图层(校正)。它包含一些小功能,我想将这些功能合并到更大的功能。 在 QGIS 中使用“消除选定的多边形”功能似乎可以解决问题,但是当我在 pyQGIS 中使用它时,没有考虑到选定的功能。
This is my layer with the selection
This is the expected output, the one from QGIS
This is my actual output, the one from pyQGIS
当我运行我的代码时,该函数不会触发 CRITICAL 错误。 The first log is my code and the second is the process without any polygon selection.
有人已经有这个问题了吗?是否可以使用另一个类似的功能? 提前致谢
QGIS 版本:3.14 (pi)
操作系统:Linux Mint 20 Ulyana(Ubuntu 焦点 20.04)
这是我的代码:
chemin_sortie = "/projet_qgis/pente/donnees_traitement/"
#Input
correction = chemin_sortie + 'correction' + '.shp'
correction_layer = iface.addVectorLayer(correction, '', 'ogr')
#Output
pente_vecteur_grand = chemin_sortie + 'pente_vecteur_grand' + '.shp'
#Selection and process
correction_layer.selectByExpression('$area < 500')
processing.run("qgis:eliminateselectedpolygons", {'INPUT':correction_layer,'MODE':2,'OUTPUT':pente_vecteur_grand})
pente_vecteur_grand_layer = iface.addVectorLayer(pente_vecteur_grand, '', 'ogr')
【问题讨论】: