Select to view content in your preferred language

Using ModelBuilder to calculate values for line segments

866
2
02-11-2014 10:38 AM
ReneeCarson
New Contributor
I am trying to build a model in Arc Desktop 10 where the sum of two fields is equal to the third field.  For example, I have a line with various segments.  In the attribute table, one of the fields is the Begin_Measure field which is 0 for the first segment.  The second field is Segment_Length which has a value (let's say 10).  The third field is the End_Measure, which should be the sum of the first two (in this case, 10).  The value of the first End_Measure becomes the value of the second Begin_Measure, and so on.

The real problem I'm having with this is that I do not have values for the Begin_Measure for any but the first segment, and I am having to run the Field Calculator for each segment.  Is there a way to build a model that will calculate the fields for each segment automatically?
Tags (2)
0 Kudos
2 Replies
RichardFairhurst
MVP Honored Contributor
I am trying to build a model in Arc Desktop 10 where the sum of two fields is equal to the third field.  For example, I have a line with various segments.  In the attribute table, one of the fields is the Begin_Measure field which is 0 for the first segment.  The second field is Segment_Length which has a value (let's say 10).  The third field is the End_Measure, which should be the sum of the first two (in this case, 10).  The value of the first End_Measure becomes the value of the second Begin_Measure, and so on.

The real problem I'm having with this is that I do not have values for the Begin_Measure for any but the first segment, and I am having to run the Field Calculator for each segment.  Is there a way to build a model that will calculate the fields for each segment automatically?


If your segments are numbered in the correct order that would chain them together to form your ultimate line for each route then you can do this with a python cursor.  You have to keep track of any RouteID change.  A variable would keep track of the accumulated lengths as each record is processed by the cursor and reset when a new route is begun.  The Field Calculator cannot do what you want, since it does not permit sort ordered record processing.
0 Kudos
ReneeCarson
New Contributor
For the most part I believe the segments are numbered in the correct order.  I am fairly new at model builder and have never used Python so I'm not sure where to even begin.
0 Kudos