0

I am using greatCircle {geosphere} function to create a map. I am able to run the code and get the desired connecting lines across the locations. But additionally I am getting an arbitrary straight line in the middle of the map. I am not able to understand why it's happening. And how it can be dropped? I am pasting the picture and the below.


library("maps")
library("geosphere")


getGreatCircle <- function(userLL,relationLL){
  tmpCircle = greatCircle(userLL,relationLL, n=200)
  start = which.min(abs(tmpCircle[,1] - data.frame(userLL)[1,1]))
  end = which.min(abs(tmpCircle[,1] - relationLL[1]))
  greatC = tmpCircle[start:end,]
  return(greatC)}

par(mar=c(0,0,0,0))

# World map
map('world',
    col="#f2f2f2", fill=TRUE, bg="white", lwd=0.05,
    mar=rep(0,4),border=0, ylim=c(-80,80))



for(i in 1:60){for(j in 1:60){ if(i != j){inter<- getGreatCircle(c(world.cities$long[i],world.cities$lat[i]),c(world.cities$long[j],world.cities$lat[j]))
lines(inter, col="skyblue", lwd=0.2)}}
  
}
  

World Trade Map

betahat
  • 1
  • 1
  • Welcome to stackoverflow. Please make your question reproducible: include the output of `dput(location)` or a sample of `location` in order to enable us to copy and paste the question to test for solutions. [For guidance on asking questions](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Peter May 17 '22 at 10:38
  • Now I have changed the code using world.cities (in built data set), so one can easily produce the results and can see the problem: there is arbitrary straight line in the middle of the graph – betahat May 17 '22 at 11:29

0 Answers0