Hi guys,
Today I had to sum the values from a field from a raster file and write the output into another. Despite you’ll think that Arcgis would have a tool to do this in a simple way, I found out that this was not necessarily the case :p
I wrote an script in python to solve this. I hope you find it useful.
What the script does is to sum the values from a field writing the result into another field in the table.
You can copy this and add it into your toolbox 🙂
The arguments that are necessary are:
#(1) table = table containing the field you want to sum
#(2) fieldtosum= the field that you are going to sum
#(3) fieldwrite= the field in which the sum is going to be writen
#Script import arcgisscripting, sys gp = arcgisscripting.create() table = sys.argv[1] fieldtosum = sys.argv[2] fieldwrite = sys.argv[3]
rows = gp.SearchCursor(table)
row = rows.Next()
p = 0.0
while row:
p += row.getvalue(fieldtosum)
print p
row = rows.next()
#calculate field
gp.calculatefield(table,sys.argv[3],float(p),”PYTHON”)
#End——-
Very soon I’ll be writing about how to do a series of variants of visibility analysis such as “Directional Viewsheds” and “Higuchi Viewsheds” that can be very useful in archaeology 🙂
Thank you for sharing this! Have you used GitHub at all? It’s fairly useful for sharing, storing, and getting comments on code.