newLonLat: Directional bearing between two geographic locations

newLonLatR Documentation

Directional bearing between two geographic locations

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

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

# 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)


marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.