0
我已经得到了我使用的地图和岩石圈的功能,看起来像一个航空地图内置的地图。但是,我想添加箭头来显示地图中“路线”的方向。您可以在下面看到我的当前工作代码(基于来自FlowingData的神奇教程)。我已经尝试过使用箭头函数代替线条函数,但我不确定如何使箭头与地圈曲线一起走,或者确保箭头沿着线条间隔,以便它们看起来像这样:如何在R中的地图上添加方向箭头?
- > - > - >
我难以置信的新R,所以任何和所有帮助将不胜感激。提前致谢。
library(maps)
library(geosphere)
read.csv("http://marsiccr.github.io/Data/airports.csv", header=TRUE, as.is=TRUE) -> airports
read.csv("http://marsiccr.github.io/Data/leaders.csv", header=TRUE, as.is=TRUE) -> flights
pal <- colorRampPalette(c("#f2f2f2", "blue"))
colors <- pal(100)
colleges<-NULL
colleges$name <- airports$insname
colleges$long <- airports$long
colleges$lat <- airports$lat
colleges
map("state")
map("state", col="#f2f2f2", fill=TRUE, bg="white", lwd=0.25)
fsub <- flights[flights$type == "aau",]
fsub <- fsub[order(fsub$cnt),]
maxcnt <- max(fsub$cnt)
for (j in 1:length(fsub$type)) {
air1 <- airports[airports$unitid == fsub[j,]$school1,]
air2 <- airports[airports$unitid == fsub[j,]$school2,]
inter <- gcIntermediate(c(air1[1,]$long, air1[1,]$lat), c(air2[1,]$long, air2[1,]$lat), n=100, addStartEnd=TRUE)
colindex <- round((fsub[j,]$cnt/maxcnt) * length(colors))
lines(inter, col=colors[colindex], lwd=0.8)
}