coords2coords              package:geoR              R Documentation

_O_p_e_r_a_t_i_o_n_s _o_n _C_o_o_r_d_i_n_a_t_e_s

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

     Functions for shifting, zooming and envolving rectangle of a set
     of coordinates.

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

     coords2coords(coords, xlim, ylim, xlim.ori, ylim.ori)

     zoom.coords(x, ...)

     ## Default S3 method:
     zoom.coords(x, xzoom, yzoom, xlim.ori, ylim.ori, xoff=0, yoff=0, ...)

     ## S3 method for class 'geodata':
     zoom.coords(x, ...)

     rect.coords(coords, xzoom = 1, yzoom=xzoom, add.to.plot=TRUE,
                 quiet = FALSE, ...)

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

coords, x: two column matrix or data-frame with coordinates.  

    xlim: range of the new x-coordinates. 

    ylim: range of the new y-coordinates. 

xlim.ori: optional. Range of the original x-coordinates, by default the
          range of the original x-coordinates.  

ylim.ori: optional. Range of the original y-coordinates, by default the
          range of the original y-coordinates.  

   xzoom: scalar, expanding factor in the x-direction.  

   yzoom: scalar, expanding factor in the y-direction.  

    xoff: scalar, shift in the x-direction.  

    yoff: scalar, shift in the y-direction.  

add.to.plot: logical, if 'TRUE' the retangle is added to the current
          plot.  

   quiet: logical, none is returned.  

     ...: further arguments to be passed to 'rect'.  

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

coords2coords and zoom.coords: return an object of the same type as
          given in the argument 'coords' with the transformed
          coordinates.  

rect.coords: returns a matrix with the 4 coordinates of the rectangle
          defined by the coordinates.  

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

     Paulo Justiniano Ribeiro Jr. paulojus@leg.ufpr.br, 
      Peter J. Diggle p.diggle@lancaster.ac.uk.

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

     'subarea', 'rect'

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

     foo <- matrix(c(4,6,6,4,2,2,4,4), nc=2)
     foo1 <- zoom.coords(foo, 2)
     foo1
     foo2 <- coords2coords(foo, c(6,10), c(6,10))
     foo2
     plot(1:10, 1:10, type="n")
     polygon(foo)
     polygon(foo1, lty=2)
     polygon(foo2, lwd=2)
     arrows(foo[,1], foo[,2],foo1[,1],foo1[,2], lty=2)
     arrows(foo[,1], foo[,2],foo2[,1],foo2[,2])
     legend(1,10, c("foo", "foo1 (zoom.coords)", "foo2 (coords2coords)"), lty=c(1,2,1), lwd=c(1,1,2), cex=1.7)

     ## "zooming" part of The Gambia map
     gb <- gambia.borders/1000
     gd <- gambia[,1:2]/1000
     plot(gb, ty="l", asp=1, xlab="W-E (kilometres)", ylab="N-S (kilometres)")
     points(gd, pch=19, cex=0.5)
     r1b <- gb[gb[,1] < 420,]
     rc1 <- rect.coords(r1b, lty=2)

     r1bn <- zoom.coords(r1b, 1.8, xoff=90, yoff=-90)
     rc2 <- rect.coords(r1bn, xz=1.05)
     segments(rc1[c(1,3),1],rc1[c(1,3),2],rc2[c(1,3),1],rc2[c(1,3),2], lty=3)

     lines(r1bn)
     r1d <- gd[gd[,1] < 420,]
     r1dn <- zoom.coords(r1d, 1.7, xlim.o=range(r1b[,1],na.rm=TRUE), ylim.o=range(r1b[,2],na.rm=TRUE), xoff=90, yoff=-90)
     points(r1dn, pch=19, cex=0.5)
     text(450,1340, "Western Region", cex=1.5)

