R/loc.map.R

Defines functions `loc.map`

`loc.map` <-
function(x,...) { 
  if (inherits(x, 'SpatialPoints')) x<-coordinates(x)
  xa <- min(x[,1])
  xb <- max(x[,1])
  if ((xb-xa)<(360-(xb-xa))) {
    x1 <- max(xa-5,-180)
    x2 <- min(xb+5,180)
    y1 <- max(min(x[,2])-5,-90)
    y2 <- min(max(x[,2])+5,90)  
    map("world",xlim=c(x1,x2),ylim=c(y1,y2))
    points(x[,1],x[,2],...)
   }
  else {
    nl <- x[,1]
    for (i in 1:length(nl)) {
      if (nl[i]<0) nl[i]<-nl[i]+360}
    x1 <- max(min(nl)-5,0)
    x2 <- min(max(nl)+5,360)
    y1 <- max(min(x[,2])-5,-90)
    y2 <- min(max(x[,2])+5,90)  
    map("world2",xlim=c(x1,x2),ylim=c(y1,y2))
    points(nl,x[,1],...)
  } 
}

Try the fossil package in your browser

Any scripts or data that you put into this service are public.

fossil documentation built on March 23, 2020, 5:06 p.m.