Hi
I wish to calculate the distance between consecutive points in a feature class.
I tried using the following code in the "Pre-Logic VBA Script Code" box in the Field Calculator dialog -
static x0 as double, y0 as double ' Previous location
dim pPoint as IPoint
set pPoint = [Shape]
x = pPoint.X
y = pPoint.Y
d = sqr((x - x0)^2 + (y - y0)^2) ' Distance
x0 = x
y0 = y
but it doesn't work. Does anyone have any suggestions? Thanks for any help anyone can give me.
x0 = 0.0 y0 = 0.0 def distance(x, y): global x0 global y0 if x0 = 0.0 and y0 = 0.0: x0 = x y0 = y d = math.sqrt((x - x0)**2 + (y - y0)**2) # Distance x0 = x y0 = y return d
Hi Richard,
great! thanks for that. One slight error the if statement should read - if x0 == 0.0 and y0 = =0.0:
Very much appreciated!
Hi Richard,
great! thanks for that. One slight error the if statement should read - if x0 == 0.0 and y0 = =0.0:
Very much appreciated!