How to add values from a field in one shapefile and put the total in another

Discussion created by johncarr on Aug 16, 2012
Latest reply on Aug 16, 2012 by clthompson
Hello all, I'm looking for a little advice with this script I am trying to write. I have a shapefile of extracted line segments that have a point from another shapefile snapped to them. The points layer has a field called "bands" that holds a numerical value. What I want to do is write a script that will look at each line segment and recognize how many points are snapped to it, read the number in each points "bands" field, add them together, and put the total in a "bands" field for the line segments. So the end result is for each line segment to have the total number of bands on the line.

So, for example if there are 2 points snapped to a particular line segment and 1 point has 3 bands and the other has 5, the script would total those up and put 8 in the "bands" field for the line segment. Then it would move on to the next segment and repeat. There arent any common ID numbers that I can use to link the 2 shapefiles up. The only relationship they have is that one is snapped to the other.

Has anyone tried anything like this before or have any ideas to get me in the right direction?