Hi Gludo and Elisabeth,I think you can use some Python to achieve this. See example below:def main():
import arcpy
# assume data is available as point featureclass
# and fc has projected coordinate system
fc = "c:/folder/yourGeodatabase.gdb/yourFCname" # change this (path to featureclass GPS points)
fldDistance = "DistGPSpoints" # change this (output name distance field)
# add distance field if it doesn't exist
if FieldExist(fc,fldDistance) == False:
arcpy.AddField_management(fc, fldDistance, "DOUBLE")
# Create update cursor for feature class
fields = ['SHAPE@XY', fldDistance]
with arcpy.da.UpdateCursor(fc, fields) as cursor:
X = 0
Y = 0
cnt = 0
for row in cursor:
cnt+=1
prevX = X
prevY = Y
X = row[0][0]
Y = row[0][1]
if cnt == 1:
# for first point distance is 0
distance = 0
else:
distance = getDist(X,Y,prevX,prevY)
# Update row
row[1] = distance
cursor.updateRow(row)
del row
def getDist(X1,Y1,X2,Y2):
import math
return math.hypot(X2 - X1, Y2 - Y1)
def FieldExist(featureclass, fieldname):
import arcpy
fieldList = arcpy.ListFields(featureclass, fieldname)
fieldCount = len(fieldList)
if (fieldCount == 1):
return True
else:
return False
if __name__ == '__main__':
main()
You will need to change the path to the featureclass and the name of the output field. It assumes the data is available as point featureclass and the point should be projected (not in a geographic coordinate system).The script will:
- add the output distance field (now named "DistGPSpoints") if it doesn't exist yet
- loop through the points and calculate the distance to the previous point
Kind regards,Xander