Tag Archives: script

Script to sum values from one field and place them into another field ARCGIS

31 May

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 🙂

How to batch merge multiple shapefiles

11 Feb

Hey guys, in one of my last posts I shared a very useful tool to split a shp into several by attribute.  I found another great script by Gerry Gabrisch but this time to merge multiple shapefiles. There are several ways to do this and if you are not that familiar establishing the arguments or parameters in a Phyton script you will probably prefer this other utility.

Tlaloc bless the internet! 😀

Have a great weekend!