newLonLat: Directional bearing between two geographic locations

Description Usage Arguments Value Examples

Description

newLonLat calculates a new lon/lat position given an sarting lon/lat position, a bearing and a distance to the new lon/lat position. Either the lon and lat arguments or the bearing and distance arguments can be a vector, whereby a vector of new locations will be calculated.

Usage

1
newLonLat(lon, lat, bearing, distance)

Arguments

lon

Longitude 1 (in decimal degrees)

lat

Latitude 1 (in decimal degrees)

bearing

Longitude 2 (in decimal degrees)

distance

Distance to new lon/lat position (km)

Value

List of new lon/lat locations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Single new lon/lat position calculation
newLonLat(0,0,45,1000)

# Vector of new lon/lat positions and plot
startPos <- list(lon=0,lat=0)
endPos <- newLonLat(startPos$lon, startPos$lat, seq(0,360,20), 1000)
plot(1, t="n", xlim=range(endPos$lon), ylim=range(endPos$lat), xlab="lon", ylab="lat")
segments(startPos$lon, startPos$lat, endPos$lon, endPos$lat, col=rainbow(length(endPos$lon)))
points(startPos$lon, startPos$lat)
points(endPos$lon, endPos$lat)

msandifo/slab documentation built on Oct. 13, 2020, 1:26 a.m.