HOW TO

Berechnen der Gesamtzahl der Felder in einer Feature-Class mit der Python-Funktion ListFields() in ArcGIS Pro

Last Published: July 21, 2023

Zusammenfassung

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.

Vorgehensweise

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.

Artikel-ID: 000023096

Benachrichtigungen erhalten und Lösungen für neue oder häufige Probleme finden

Unser neuer KI-Chatbot stellt zusammengefasste Antworten und Videolösungen für Sie bereit.

Esri Support App herunterladen

Zugehörige Informationen

Weitere Informationen zu diesem Thema erkunden

Unterstützung durch ArcGIS-Experten anfordern

An den technischen Support wenden

Esri Support App herunterladen

Zu Download-Optionen wechseln