Saturday, 31 January 2015

arcgis desktop - Referencing other points(rows) in field calculator


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




Answer



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...