I ran into this problem when I wanted to show road segments' total volumes as one single label for each segment, but our feature class has features for both directions of the roadways with separate volumes for each direction.
Is there a way to sum together the PCE_VOLU_3 field for each feature with the same attributes for the NO field? Any scripting solutions(python would be preferred)? I figured out a way to accomplish this in Excel by creating a formula by identifying cells, but I would much prefer to find a way to accomplish this in Arc map.
Any help would be appreciated.
Thank you,
Jacob
Solved! Go to Solution.
The Summary Statistics tool will produce a separate table. You can always join this back to your original data if you want to use the values for labels, etc.
Check out the Summary Statistics tool. You could SUM the PCE_VOLU_3 fields using NO as your case field.
Once you sum the values, how do you want to store them? Do you want a separate table? Do you want a new column in this table where is shows the same sum for all of the records with the same NO?
A separate table would be best.
The Summary Statistics tool will produce a separate table. You can always join this back to your original data if you want to use the values for labels, etc.
As Owen Earley suggests, the Summary Statistics tool should work, and it is scriptable through Python.
You could also use a data access (arcpy.da) search cursor approach, a bit more involved but likely more performant than Summary Statistics.
# import functions from modules that are available but not commonly imported from collections import defaultdict from numpy import fromiter, dtype # sum PCE_VOLU_3 by NO stats = defaultdict(int) with arcpy.da.SearchCursor(input_fc, ['NO','PCE_VOLU_3']) as cur: for k, v in cur: stats+= v # create iterable and populate numpy array stats_iterable = ((k, v) for (k, v) in stats.iteritems()) tmp1 = fromiter(stats_iterable, dtype([('NO', 'i4'), ('SUM_PCE_', 'f8')])) # Dump numpy array to table arcpy.da.NumPyArrayToTable(tmp1, out_table) del tmp1 del stats