There is a reason for the Posting Guide requesting that a reproducible example be offered. There is also a reason for the PG requesting that you not crosspost to r-help.

http://stackoverflow.com/questions/13549080/antipodal-error-in-great-circles-code

--
David.
On Nov 24, 2012, at 11:04 PM, shabsae wrote:

Hey,

I'm trying to build something like this
http://flowingdata.com/2011/05/11/how-to-map-connections-with-great-circles/
but with my own data in csv files.
The code runs well if I use the same csv files as the author, but with mine
, this is what I get

*Code*

library(maps)
library(geosphere)


map("world")

xlim <- c(-180.00, 180.00)

ylim <- c(-90.00, 90.00)

map("world", col = "#f2f2f2", fill = TRUE, bg = "white", lwd = 0.05,xlim =
xlim, ylim = ylim)

airports <- read.csv("/Users/shabnam/Desktop/airports.csv", as.is=TRUE,
header=TRUE)
flights <- read.csv("/Users/shabnam/Desktop/flights.csv", as.is=TRUE,
header=TRUE)

pal <- colorRampPalette(c("#545454", "white"))colors <- pal(100)
map("world", col="#303030", fill=TRUE, bg="black", lwd=0.05, xlim=xlim,
ylim=ylim)


fsub <- flights[flights$airline == "AA",]


fsub <- fsub[order(fsub$cnt),]

maxcnt <- max(fsub$cnt)

for (j in 1:length(fsub$airline))
{
air1 <- airports[airports$iata == fsub[j,]$airport1,]

air2 <- airports[airports$iata == fsub[j,]$airport2,]

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




David Winsemius, MD
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to