[R] R maps Help
Ray Brownrigg
Ray.Brownrigg at ecs.vuw.ac.nz
Sun Feb 10 02:15:30 CET 2013
I don't understand what you mean by "too small", and you haven't
provided a reproducible example.
The map will be as large as the default graphics window on your screen
will allow (leaving room for axes and labels as well).
If you are not happy with this, try something like:
x11(width=30, height=18)
map_world()
Otherwise, you will need to describe exactly what you mean by "really
too small to show the data effectively" and provide a reproducible example.
Ray Brownrigg
On 10/02/2013 5:06 a.m., Frank Rodgers wrote:
> I am fairly new to R and am plotting flight data on a map. Everything is
> working well except the size of the map is really too small to show the data
> effectively and I can't seem to figure out how to make the output map
> larger. Do I need to change the device characteristics or is it a map.???
> call. Here is the code:
>
> library(maps)
> library(geosphere)
>
> airports <- read.csv("airports.csv", header=TRUE)
> flights <- read.csv("FSRflights.csv", header=TRUE, as.is=TRUE)
>
> checkDateLine <- function(l){
> n<-0
> k<-length(l)
> k<-k-1
> for (j in 1:k){
> n[j] <- l[j+1] - l[j]
> }
> n <- abs(n)
> m<-max(n, rm.na=TRUE)
> ifelse(m > 30, TRUE, FALSE)
> }
>
> clean.Inter <- function(p1, p2, n, addStartEnd){
> inter <- gcIntermediate(p1, p2, n=n, addStartEnd=addStartEnd)
> if (checkDateLine(inter[,1])){
> m1 <- midPoint(p1, p2)
> m1[,1] <- (m1[,1]+180)%%360 - 180
> a1 <- antipode(m1)
> l1 <- gcIntermediate(p1, a1, n=n, addStartEnd=addStartEnd)
> l2 <- gcIntermediate(a1, p2, n=n, addStartEnd=addStartEnd)
> l3 <- rbind(l1, l2)
> l3
> }
> else{
> inter
> }
> }
>
> add_lines <- function(){
> pal <- colorRampPalette(c("#00FF00", "#FF0000"))
> colors <- pal(100)
>
> fsub <- flights[flights$airline == "FSR",]
> fsub <- flights[order(flights$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,]
> p1 <- c(air1[1,]$long, air1[1,]$lat)
> p2 <- c(air2[1,]$long, air2[1,]$lat)
>
> inter <- clean.Inter(p1,p2,n=100, addStartEnd=TRUE)
> colindex <- round( (fsub[j,]$cnt / maxcnt) * length(colors))
>
> lines(inter, col=colors[colindex], lwd=0.1)
> }
> }
>
>
> map_usa <- function(){
> xlim <- c(-171.738281, -56.601563)
> ylim <- c(12.039321, 71.856229)
> map("world", col="#191919", fill=TRUE, bg="#736F6E", lwd=0.05, xlim=xlim,
> ylim=ylim)
> add_lines()
> }
>
> map_world <- function(){
> map("world", col="#191919", fill=TRUE, bg="#736F6E", lwd=.1)
> add_lines()
> }
>
> map_world()
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-maps-Help-tp4658030.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list