hi jenkins.macedo,
my original script calculated the distance between two consecutive rows in kilometers.
i have now amended it to produce the miles distance for each row.
try this on your table
Clear Globals();
Names Default To Here( 1 );
// reference the data table
dt = current data table();
// introduce the column with the distance to be updated in the dots table
dt << add multiple columns( "Distance", 1, after( 6 ), numeric );
// extract the longitude and the latitude values from the table - as radians
HHx = (Column( dt, "HH Longitude" ) << getValues) * Pi() / 180 ;
HHy = (Column( dt, "HH Latitude" ) << getValues) * Pi() / 180 ;
PSx = (Column( dt, "PS Longitude" ) << getValues) * Pi() / 180 ;
PSy = (Column( dt, "PS Latitude" ) << getValues) * Pi() / 180 ;
// declare the calculation function in Miles
haversine = Function( {long1, lat1, long2, lat2, R = 6371},
{Default Local},
a = Sin( (lat1 - lat2) / 2 ) ^ 2 + Cos( lat1 ) * Cos( lat2 ) * Sin( (long1 - long2) / 2 ) ^ 2;
c = 2 * ATan( a ^ 0.5, (1 - a) ^ 0.5 );
d = (R * c)*0.6213712;// miles
);
wait (0.01);
// run the function along the rows of the table
For( i = 1, i <= N Row( dt ) - 1, i++,
dt:distance[i] = haversine( HHx[i], HHy[i], PSx[i], PSy[i] )
);