geodDist(lat1, lon1, lat2, lon2)
If the first argument is an object of class section
, the result
is vector containing the distances of the individual stations from the
first one in the section.
If the first argument is a vector, then the "1" and "2" vectors are of equal length, then the result is the pairwise distances. However, if the length of "2" is shorter than the length of "1", then only the first value in the "2" vector is used, repeated over and over to match the length of "1".
A common use is for "1" to contain a vector of positions along a
cruise track, and for "2" to contain a reference point;
e.g. geodDist(lats,lons,lats[1],lons[1])
gives distance along
the track starting from zero.
geodXy
# There are roughly 111km per degree of latitude
km <- geodDist(45, 100, 46, 100)/1000
Run the code above in your browser using DataLab