I am trying to calculate distance between one location and all other locations from their latitudes and longitudes.
I have been using distanceTrack from the argosfilter package to calculate the distance between consectuive locations which works very simply as this is a the code I need to make it work:
lat<-lizard$Latitude lon<-lizard$Longitude distanceTrack(lat, lon) But now I am wanting to calculate the distance between the first location and the second location, and then the distance between the first and third location, etc. for all locations.
I have been looking for a way to do this quickly as the only way I have been able to do it is manually copying and pasting the desired coordinates into a different csv file and then uploading it to R and running the above code, which is arduous. I am thinking an apply function or something similar might work. So would an apply function be the right way forward? And I don't know how to write the code to specify the rows to calculate the distance between, so any help with that would be great.
sp::spDistsN1orgeosphere::distVincentyEllipsoid(and related functions in the geosphere package).