2

I found this great tutorial on how to use maps and geosphere to connect points on a map in R using great circles:

https://flowingdata.com/2011/05/11/how-to-map-connections-with-great-circles/

Is there a way to make the lines go the other way if they run off the edge of the map (cross the international dateline):

map

My current code looks like this for a line connecting DC to Beijing:

library(maps) 
library(geosphere)

map("world")

lat_ca <- 38.89511
lon_ca <- -77.03637
lat_me <- 39.917
lon_me <- 116.383
inter <- gcIntermediate(c(lon_ca, lat_ca), c(lon_me, lat_me), n=50, addStartEnd=TRUE)# breakAtDateLine=TRUE) 


lines(inter)

to be clear, I would like to end up with something that looks like this:

the long way around

It seems like this would be the other arc of a great circle in the same plane as the first one but I can't figure out how to draw it.

www
  • 38,575
  • 12
  • 48
  • 84
user3390169
  • 1,015
  • 1
  • 11
  • 34
  • 1
    Well, you wanted the shortest distance and you got it :) : `library(ggplot2); inter <- gcIntermediate(c(lon_ca, lat_ca), c(lon_me, lat_me), n=50, addStartEnd=TRUE, breakAtDateLine=T); ggplot(do.call(rbind, lapply(seq(inter), function(x) transform(as.data.frame(inter[[x]]), id=x))), aes(lon, lat, group=id)) + borders(fill="#333333") + coord_map("ortho", orientation=c(90, 0, 0)) + geom_line(color="red")`. Maybe you just need `map("world"); diagram::curvedarrow(c(lon_ca, lat_ca), c(lon_me, lat_me), curve=.1)`? – lukeA Dec 17 '15 at 16:46
  • Thanks! this worked for what I was trying to do – user3390169 Dec 17 '15 at 20:04

0 Answers0