hello , i have 8 points with Z value .
each 2 points is a pair ( see the colors in the image attached).
i created a new feild calles "Delta" that in their i want the result of the difference between a pair..
for example the difference between point 2 to 1 is 4.66 meters..
is there a way to do this via while or for loop ?
thanks for the help!
Using the field calculator with a Python 3 expression, use this formula to populate the records with an even OBJECTID with the Delta between the current and previous Z value.
Expression:
GetDelta(!OBJECTID!, !Z!)
Code Block:
previousZ = 0
def GetDelta(objectId, zValue):
global previousZ
# Don't calculate Delta for odd numbered OBJECTIDs
if (objectId % 2 != 0):
previousZ = zValue
return None
if (previousZ):
#Get the absolute value of the difference
difference = abs(zValue - previousZ)
else:
difference = 0
#Update the previousZ global variable with the latest Z value
previousZ = zValue
return difference
This would have to be run on all records or an even number of records starting with an odd value.