4

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

4

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:

prev=None
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? – Kirk Kuykendall Mar 31 '16 at 20:11
  • @KirkKuykendall, not sure, though I assume so. Interesting point... – Paul Mar 31 '16 at 21:01
  • Yes it does. BTW return none is missing after 1st prev assignment – FelixIP Apr 1 '16 at 3:48
  • 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 Apr 4 '16 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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