I have a data frame of the form
lon1 | lat1 | lon2 | lat2 |
---|---|---|---|
... | ... | ... | ... |
... | ... | ... | ... |
representing coordinates of pairs of points. How do I do to calculate the geodesic distance between the pairs in a new column? There is the package geosphere
which can do this for pairs of points of the form distm(c(lon1, lat1), c(lon2, lat2))
. Is there a way to apply this directly to the columns?