简体   繁体   English

Qgis Python控制台,计算多边形中的独特特征

[英]Qgis Python Console, Count unique features in polygons

Hello I am using the python console to count the number of unique features of points in a polygon layer. 您好,我正在使用python控制台计算多边形图层中点的唯一特征的数量。 Here is the link where I'm replicating the code link . 这是我要复制代码链接的链接

Here is what my code looks like: 这是我的代码:

processing.runalg('qgis:countuniquepointsinpolygon', poly, pts, "fclass", "pt_count", res)

poly is my polygon layer, pts is my points layer, "fclass" is the field name in pts layer, "pt_count" will be the field where the unique feature counts will go into, and res is the new polygon to be created with "pt_count" field in it. poly是我的多边形层, pts是我的点层, "fclass"pts层中的字段名称, "pt_count"将是唯一要素计数将进入的字段, res是将要使用"pt_count"创建的新多边形"pt_count"字段。

when I run the code I get the following error: 当我运行代码时,出现以下错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'res' is not defined

the field "fclass" from pts looks like this: Image 现场"fclass"pts看起来是这样的: 图片

Is there a reason why I get this error if res is suppose to be created? 如果应该创建res是否有我为什么会收到此错误的原因?

Did you try passing a filename as res ? 您是否尝试将文件名作为res传递? For example: 例如:

processing.runalg('qgis:countuniquepointsinpolygon', poly, pts, "fclass", "pt_count", "myresult.shp")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM