CÓMO
En ArcGIS Pro, la función sum() de la herramienta Calcular campo se puede utilizar para calcular la suma de cada registro a partir de una lista de campos numéricos. Sin embargo, cuando la tabla o clase de entidad contiene un gran número de campos, no es práctico seleccionar manualmente todos los campos numéricos.
La secuencia de comandos de ArcPy proporcionada en este artículo se puede utilizar para calcular la suma de los valores de todos los campos numéricos de una tabla o clase de entidad.
En este ejemplo, hay cinco campos numéricos en la clase de entidad 'Point1', como se muestra en la siguiente imagen.

import arcpy
# Set the path to the feature class or the table
table = r""
# Add a new field to the table
arcpy.management.AddField(table, "SumField", "DOUBLE")
# Use UpdateCursor to iterate through the rows of the table
with arcpy.da.UpdateCursor(table, "*") as cursor:
for row in cursor:
# Initialize a variable to store the sum
total = 0
# Iterate through each field in the row
for i in range(len(row)):
# Check if the field is numeric and not OBJECTID, Shape_Length, and Shape_Area
if isinstance(row[i], (int, float, complex)) and cursor.fields[i] not in ['OBJECTID', 'Shape_Length', 'Shape_Area']:
# Add the field's value to the total
total += row[i]
# Update the new field with the total
row[cursor.fields.index('SumField')] = total
cursor.updateRow(row)
La suma de los campos numéricos de cada entidad ahora se rellena en el nuevo campo, 'SumField'.

Id. de artículo: 000029132
Obtener ayuda de expertos en ArcGIS
Empieza a chatear ahora