方法

ArcGIS Pro で Python の ListFields() を使用し、フィーチャクラスの合計フィールド数を計算する

Last Published: July 21, 2023

サマリー

In ArcGIS Pro, the Get Count geoprocessing tool is used to calculate the total number of rows in an attribute table. However, this tool does not calculate the total number of columns, which represents the total number of fields in a feature class.

Providing a method to calculate this is helpful when there is a large number of attributes in a feature class. This is achieved using the Python ListFields() function.

An attribute table of a feature class.

手順

Follow the workflow below to calculate the total number of fields in a feature class using the Python ListFields() function.

  1. In ArcGIS Pro, on the Analysis tab, click the down arrow next to Python, and select Python window.
the Analysis tab and the drop-down menu of the Python button. Python Notebook and Python window are listed in the drop-down menu.
  1. In the Python window, in the prompt section, enter the Python ListFields() function as shown below. Refer to ArcGIS Pro: ListFields for more information.
import arcpy
fields = arcpy.ListFields('Feature Class Name')
print(len(fields))
Note:
Do not remove the single quotation marks enclosing the feature class name.

In this example, the feature class is Asia.

The Python window prompt section.
  1. Place the cursor at the end of the expression and press Enter twice on the keyboard. The image below shows the total number of fields for the Asia feature class is 8.
The Python window with the result after executing the ListField funtion.

記事 ID: 000023096

新しい問題や一般的な問題に対する通知とソリューションの受け取り

新しい AI チャットボットから、要約された回答とビデオソリューションを入手してください。

Esri Support アプリのダウンロード

関連情報

このトピックについてさらに調べる

ArcGIS エキスパートのサポートを受ける

テクニカル サポートへのお問い合わせ

Esri Support アプリのダウンロード

ダウンロード オプションに移動