为什么arcpy中的len()函数与实际情况不匹配

huangapple go评论77阅读模式
英文:

Why function len() in arcpy mismatch with in fact

问题

I would like to know I use the function len() in Arcpy and why the values that return does not match the fact.

from the function, len returns 12 but in fact list fields have 21. Please see my code

big = arcpy.ListFields('ลพบุรี_PSU_Select')
boss = len(big)
print(boss)

我想知道为什么我在Arcpy中使用len()函数时,返回的值与实际情况不符。

从函数中,len返回12,但实际上字段列表有21个。请查看我的代码

为什么arcpy中的len()函数与实际情况不匹配

I would like the len function to return the correct value.

英文:

I would like to know I use the function len() in Arcpy and why the values that return does not match the fact.

from the function, len returns 12 but in fact list fields have 21. Please see my code

big=arcpy.ListFields('ลพบุรี_PSU_Select')
boss=len(big)
print(boss)

为什么arcpy中的len()函数与实际情况不匹配

I would like to len function return follow true

答案1

得分: 2

The caption "1 of 21 selected" refers to the number of features (rows). There are 21 features in the layer, and one of them is selected.

In contrast, the ListFields function is meant to return all the fields (columns) of the layer. This layer has 12 fields (OBJECTID, SHAPE, PSUNUM, ...).

英文:

The caption "1 of 21 selected" refers to the number of features (rows). There are 21 features in layer, and one of them is selected.

In contrast, the ListFields function is meant to return all the fields (columns) of the layer. This layer has 12 fields (OBJECTID, SHAPE, PSUNUM, ...).

答案2

得分: 0

你可以使用以下方法来获取要素行数:

rows_amount = int(arcpy.management.GetCount('ลพบุรี_PSU_Select').getOutput(0))

ListFields 函数返回指定要素类的字段列表,通常包含 12 个字段。

英文:

If you want to get the amount of the features\rows you can use the GetCount method as follows:

rows_amount = int(arcpy.management.GetCount('ลพบุรี_PSU_Select').getOutput(0))

The ListFields function returns a list of the fields for a specified feature class, which is likely to have 12 fields.

huangapple
  • 本文由 发表于 2023年3月7日 18:42:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75660944.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定