View source: R/extendr-wrappers.R
haversine_destination | R Documentation |
Given a vector of point geometries, bearings, and distances, identify a destination location.
haversine_destination(x, bearing, distance)
x |
an object of class |
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 |
an object of class rs_POINT
# 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.