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) } -- View this message in context: http://r.789695.n4.nabble.com/Error-Error-in-if-antipodal-p1-p2-tp4650712.html Sent from the R help mailing list archive at Nabble.com.
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
Possibly Parallel Threads
- R maps Help
- How to do a time-stratified case-crossover analysis for air pollution data?
- How to do a time-stratified case-crossover analysis for air pollution data? Unformatted text-version, with an additional note
- Could not find createData function
- merging data frames gives all NAs