Skip to contents

Given a vector of point geometries, bearings, and distances, identify a destination location.

Usage

haversine_destination(x, bearing, distance)

Arguments

x

an object of class rs_POINT

bearing

a numeric vector specifying the degree of the direction where 0 is north

distance

a numeric vector specifying the distance to travel in the direction specified by bearing in meters

Value

an object of class rs_POINT

Examples

# create 10 points at the origin
pnts <- geom_point(rep(0, 10), rep(0, 10))

# set seed for reproducibiliy
set.seed(1)

# generate random bearings
bearings <- runif(10, 0, 360)

# generate random distances
distances <- runif(10, 10000, 100000)

# find the destinations
dests <- haversine_destination(pnts, bearings, distances)

# plot points
if (rlang::is_installed(c("sf", "wk"))) {
  plot(pnts, pch = 3)
  plot(dests, add = TRUE, pch = 17)
}