image                 package:gstat                 R Documentation

_I_m_a_g_e _G_r_i_d_d_e_d _C_o_o_r_d_i_n_a_t_e_s _i_n _D_a_t_a _F_r_a_m_e

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

     Image gridded data, held in a data frame, keeping the right aspect
     ratio for axes, and the right cell shape

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

     image.data.frame(x, zcol = 3, xcol = 1, ycol = 2, ...)
     xyz2img(xyz, zcol = 3, xcol = 1, ycol = 2)

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

       x: data frame (or matrix) with x-coordinate, y-coordinate, and
          z-coordinate in its columns 

    zcol: column number of z-variable 

    xcol: column number of x-coordinate 

    ycol: column number of y-coordinate 

     ...: arguments, passed to image.default 

     xyz: data frame (same as 'x')

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

     image.data.frame plots an image from gridded data, organized in
     arbritrary order, in a data frame. It uses xyz2img and
     image.default for this. In the S-Plus version, xyz2img tries to
     make an image object with a size such that it will plot with an
     equal aspect ratio; for the R version, image.data.frame uses the
     'asp=1' argument to guarantee this.

     xyz2img returns a list with components: 'z', a matrix containing
     the z-values; 'x', the increasing coordinates of the rows of 'z';
     'y', the increasing coordinates of the columns of 'z'. This list
     is suitable input to image.default.

_N_o_t_e:

     I wrote this function before I found out about 'levelplot', a
     Lattice/Trellis function that lets you control the aspect ratio by
     the 'aspect' argument, and that automatically draws a legend, and
     therefore I now prefer levelplot over 'image'. Plotting points on
     a levelplots is probably done with providing a panel function and
     using 'lpoints'.

     (for S-Plus only - ) it is hard (if not impossible) to get exactly
     right cell shapes (e.g., square for a square grid) without
     altering the size of the plotting region, but this function tries
     hard to do so by extending the image to plot in either x- or
     y-direction.  The larger the grid, the better the approximation.
     Geographically correct images can be obtained by modifiying
     'par("pin")'. Read the examples, image a 2 x 2 grid, and play with
     'par("pin")' if you want to learn more about this.

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

     Edzer J. Pebesma

_R_e_f_e_r_e_n_c_e_s:

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

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

     data(meuse)
     data(meuse.grid)
     g <- gstat(formula=log(zinc)~1,locations=~x+y,data=meuse,model=vgm(1,"Exp",300))
     x <- predict(g, meuse.grid)
     image(x, 4, main="kriging variance and data points")
     points(meuse$x, meuse$y, pch = "+")
     # non-square cell test:
     image(x[((x$y - 20) %% 80) == 0,], main = "40 x 80 cells")
     image(x[((x$x - 20) %% 80) == 0,], main = "80 x 40 cells")
     # the following works for square cells only:
     oldpin <- par("pin")
     ratio <- length(unique(x$x))/length(unique(x$y))
     par(pin = c(oldpin[2]*ratio,oldpin[2]))
     image(x, main="Exactly square cells, using par(pin)")
     par(pin = oldpin)
     levelplot(var1.var~x+y, x, aspect = mapasp(x), main = "kriging variance")

