geolocate.R
This file should contain your function and be saved at:
R/geolocate.R
Create the file using:
::use_r("geolocate") usethis
Your script should contain:
# Function
<- function(decimalLongitude, decimalLatitude,
get_stem_location
stemAzimuth, stemDistance) {# check inputs are correct type (numeric)
::assert_numeric(decimalLatitude)
checkmate::assert_numeric(decimalLongitude)
checkmate::assert_numeric(stemAzimuth)
checkmate::assert_numeric(stemDistance)
checkmate
<- geosphere::destPoint(p = cbind(decimalLongitude, decimalLatitude),
out b = stemAzimuth, d = stemDistance) %>%
::as_tibble()
tibble
# check output for NAs
::assert_false(any(is.na(out)))
checkmate
return(out)
}