distance | R Documentation |
Wraps distVincentyEllipsoid
in tidy semantics to
compute and add the shortest distance between to points on a globe to a
table of coordinates.
distance(
.data,
lat = lat,
long = long,
lat_from = NULL,
long_from = NULL,
dist_col = "dist",
along = TRUE,
...
)
.data |
a tbl with coordinates in degrees |
lat, long |
latitude and longitude columns (unquoted) |
lat_from, long_from |
optional reference point coordinates |
dist_col |
name of the output column |
along |
if TRUE return cumulative distances along points |
... |
arguments passed on to distVincentyEllipsoid |
stations <- tibble(
lat=c(50,55,60),
long=c(180,180,180)
)
# cumulative distance along transect stations
stations %>% distance
# distances to almost Greenwich
stations %>%
distance(lat_from=0, long_from=0, along=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.