nowrapRecenter           package:maptools           R Documentation

_B_r_e_a_k _p_o_l_y_g_o_n_s _a_t _m_e_r_i_d_i_a_n _f_o_r _r_e_c_e_n_t_e_r_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     When recentering a world map, say to change an "Atlantic" view
     with longitude range -180 to 180, to a "Pacific" view, with
     longitude range 0 to 360, polygons crossed by the new offset, here
     0/360, need to be clipped into left and right sub.polygons to
     avoid horizontal scratches across the map. The
     'nowrapSpatialPolygons' function performs this operation using
     polygon intersection, and 'nowrapRecenter' recenters the output
     SpatialPolygons object.

_U_s_a_g_e:

     nowrapRecenter(obj, offset = 0, eps = rep(.Machine$double.eps, 2))
     nowrapSpatialPolygons(obj, offset = 0, eps=rep(.Machine$double.eps, 2))

_A_r_g_u_m_e_n_t_s:

     obj: A SpatialPolygons object 

  offset: offset from the Greenwich meridian 

     eps: vector of two (left and right) fuzz factors to retract the
          ring from the offset

_V_a_l_u_e:

     A SpatialPolygons object

_A_u_t_h_o_r(_s):

     Roger Bivand

_S_e_e _A_l_s_o:

     'recenter', 'nowrapSpatialLines'

_E_x_a_m_p_l_e_s:

     library(gpclib)
     ## Not run: 
     library(maps)
     world <- map("world", fill=TRUE, col="transparent", plot=FALSE)
     worldSpP <- map2SpatialPolygons(world, world$names, CRS("+proj=longlat"))
     worldSpPr <- recenter(worldSpP)
     plot(worldSpPr)
     title("Pacific view without polygon splitting")
     worldSpPnr <- nowrapRecenter(worldSpP)
     plot(worldSpPnr)
     title("Pacific view with polygon splitting")
     ## End(Not run)
     crds <- matrix(c(-1, 1, 1, -1, 50, 50, 52, 52), ncol=2)
     rcrds <- rbind(crds, crds[1,])
     SR <- SpatialPolygons(list(Polygons(list(Polygon(rcrds)), ID="r1")),
      proj4string=CRS("+proj=longlat"))
     bbox(SR)
     SRr <- recenter(SR)
     bbox(SRr)
     SRnr <- nowrapRecenter(SR)
     bbox(SRnr)

