Skip to content

map2SpatialLines and map('world2')

2 messages · Rob Hodges, Roger Bivand

#
On Sat, 2 Jul 2011, Rob Hodges wrote:

            
[1]  -5.072266 369.988892 -85.443077  83.573914
[1] -179.95721  190.29080  -85.44308   83.57391

where the world2 data falls foul of:
function (bb)
{
     tol <- .Machine$double.eps^0.25
     W <- bb[1, 1] < -180 && !isTRUE(all.equal((bb[1, 1] - -180),
         0, tolerance = tol))
     E <- bb[1, 2] > 360 && !isTRUE(all.equal((bb[1, 2] - 360),
         0, tolerance = tol))
     S <- bb[2, 1] < -90 && !isTRUE(all.equal((bb[2, 1] - -90),
         0, tolerance = tol))
     N <- bb[2, 2] > 90 && !isTRUE(all.equal((bb[2, 2] - 90),
         0, tolerance = tol))
     return(!(any(W || E || S || N)))
}
<environment: namespace:sp>

and its limit at just over 360 degrees. If what you need are lines as a 
background, then pruneMap() may help:

x_pac_sl = map2SpatialLines(pruneMap(x_pac, xlim=c(0, 360)),
   proj4string=CRS("+proj=longlat +datum=WGS84"))

by trimming lines. Alternatives through recenter methods often lead to 
horizonal stripes.

Hope this helps,

Roger