distance: Compute great circle distances

View source: R/geography.R

distanceR Documentation

Compute great circle distances

Description

Wraps distVincentyEllipsoid in tidy semantics to compute and add the shortest distance between to points on a globe to a table of coordinates.

Usage

distance(
  .data,
  lat = lat,
  long = long,
  lat_from = NULL,
  long_from = NULL,
  dist_col = "dist",
  along = TRUE,
  ...
)

Arguments

.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

Examples

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)

thackl/thacklr documentation built on Oct. 16, 2023, 9:15 p.m.