I'm trying to calculate an angle between points using a field calculator. Is it possible to reference the previous or next FID with reference to the current one using the field calc?

Eventually I'd like to have an angle between the next and previous point be input into a field for the current point - like shown below

enter image description here


1 Answer 1


Yes, you can access previous values with Field Calculator. I'd suggest migrating to Python and using update cursors, where it would be a lot simpler to work with values forward (via reading into a list) or reverse.

Code Block:

def diff(curr): 
  global prev
  if prev is None:
    prev = curr
  res = curr - prev
  prev = curr
  return res

Expression: diff(!test!)

enter image description here

  • 1
    Do you know if field calculator is guaranteed to process features in order by FID? Commented Mar 31, 2016 at 20:11
  • @KirkKuykendall, not sure, though I assume so. Interesting point...
    – Paul
    Commented Mar 31, 2016 at 21:01
  • Yes it does. BTW return none is missing after 1st prev assignment
    – FelixIP
    Commented Apr 1, 2016 at 3:48
  • 1
    File geodatabase and shapefile will always process features in order, but enterprise geodatabases are free to process rows in any order (unless an ORDER BY has been specified).
    – Vince
    Commented Apr 4, 2016 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.