bearing
当我使用包中的函数计算点之间的geosphere
方位角时,得到的方位角跨度为 -180 - 180 度。但是,根据geosphere
包装文档,我预计轴承可以跨越 0-360 度。这是文档中的引用:
方向以度数表示(北 = 0 和 360,东 = 90,南 = 180,西 = 270 度)。
我错过了什么?
这是一个小例子:
# set up
library(geosphere)
library(ggplot2)
# create data frame of long/lat
long <- c(-55.25, -55.25, -55.25, -55, -55, -55, -54.75, -54.75, -54.75)
lat <- c(-13.5, -13.25, -13, -13.5, -13.25, -13, -13.5, -13.25, -13)
id <- c("a", "b", "c", "d", "e", "f", "g", "h", "i")
pts <- data.frame(id=id, long=long, lat=lat)
# plot
ggplot(pts, aes(x=long, y=lat, colour=id)) +
geom_point()
# calculate bearings from point e to all other points
pts <- pts[,c(2:3)]
b <- bearing(pts[5,], pts)
# I expected this:
# b[1] = 225
# b[2] = 270
# b[3] = 315
# but instead, found this:
b[1]
b[2]
b[3]