geo_points_bearing: Bearing Between Two Latitude and Longitude Points

Description Usage Arguments Value Author(s) See Also Examples

View source: R/geo_points_bearing.R

Description

Calculates the bearing angle in degrees between two latitude, longitude points

Usage

1
geo_points_bearing(coordinate_pair)

Arguments

coordinate_pair

A matrix of latitude and longitude columns and two rows of points

Value

A vector of length 1 containing a bearing

Author(s)

Shant Sukljian

See Also

geo_sed geo_point_dist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Load required packages
require(mapview)
require(sp)

# Create sample geo dataset
sample_coord <-
   matrix(
        c(
            sample(327131680:419648450, 2) / 10000000,
            sample(-1147301410:-1241938690, 2) / 10000000
        ),
        ncol = 2
    )

# Calculate bearing
(gpb <- geo_points_bearing(sample_coord))

# Create SpacialPoints object and pass to mapview for visualization
mapview(
    SpatialPoints(
        sample_coord[,c(2, 1)],
        proj4string = CRS("+proj=longlat +datum=WGS84")
    )
)

geosed documentation built on Sept. 3, 2019, 9:04 a.m.