image.SpatialGridDataFrame        package:sp        R Documentation

_i_m_a_g_e _g_r_i_d_d_e_d _s_p_a_t_i_a_l _d_a_t_a, _o_r _c_o_n_v_e_r_t _t_o _f_o_r_m_a_t _f_o_r _i_m_a_g_e

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

     Convert gridded data in SpatialGridDataFrame to image format; call
     image on data in SpatialGridDataFrame format. The aspect ratio is
     set as either 1 for projected data, or stretched by distance from
     Equator for geographical coordinates.

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

     ## S3 method for class 'SpatialGridDataFrame':
     image(x, attr = 1, xcol = 1, ycol = 2, 
             col = heat.colors(12), red=NULL, green=NULL, blue=NULL,
             axes = FALSE, xlim = NULL,
             ylim = NULL, add = FALSE, ..., asp = NA, setParUsrBB=FALSE)
     ## S3 method for class 'SpatialPixelsDataFrame':
     image(x, ...) 
     ## S3 method for class 'SpatialGridDataFrame':
     contour(x, attr = 1, xcol = 1, ycol = 2,
             col = 1, add = FALSE, xlim = NULL, ylim = NULL, axes = FALSE,
              ..., setParUsrBB = FALSE)
     ## S3 method for class 'SpatialPixelsDataFrame':
     contour(x, ...) 
     as.image.SpatialGridDataFrame(x, xcol = 1, ycol = 2)
     image2Grid(im, p4 = as.character(NA))

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

       x: object of class SpatialGridDataFrame 

    attr: column number of attribute variable; this may be the column
          name in the data.frame of 'data' (as.data.frame(data)), or a
          column number 

    xcol: column number of x-coordinate, in the coordinate matrix 

    ycol: column number of y-coordinate, in the coordinate matrix 

     col: a vector of colors 

red,green,blue: columns names or numbers given instead of the 'attr'
          argument when the data represent an image encoded in three
          colour bands on the 0-255 integer scale; all three columns
          must be given in this case, and the attribute values will be
          constructed using function 'rgb' 

    axes: logical; should coordinate axes be drawn? 

    xlim: x-axis limits 

    ylim: y-axis limits 

     add: logical; if FALSE, the image is added to the plot layout
          setup by 'plot(as(x,
          "Spatial"),axes=axes,xlim=xlim,ylim=ylim,asp=asp)' which sets
          up axes and plotting region; if TRUE, the image is added to
          the existing plot. 

     ...: arguments passed to image, see examples 

     asp: aspect ratio to be used for plot 

setParUsrBB: default FALSE, see 'Spatial-class' for further details

      im: list with components named x, y, and z, as used for 'image'

      p4: CRS object, proj4 string

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

     'as.image.SpatialGridDataFrame' returns the list with elements 'x'
     and 'y', containing the coordinates of the cell centres of a
     matrix 'z', containing the attribute values in matrix form as
     needed by image.

_N_o_t_e:

     Providing 'xcol' and 'ycol' attributes seems obsolete, and it is
     for 2D data, but it may provide opportunities for plotting certain
     slices in 3D data. I haven't given this much thought yet.

     filled.contour seems to misinterpret the coordinate values, if we
     take the image.default manual page as the reference.

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

     Edzer J. Pebesma

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

     image.default, SpatialGridDataFrame-class, levelplot in package
     'lattice'. Function image.plot can be used to make a legend for an
     image, see an example in <URL:
     https://stat.ethz.ch/pipermail/r-sig-geo/2007-June/002143.html>

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

     data(meuse.grid)
     coordinates(meuse.grid) = c("x", "y") # promote to SpatialPointsDataFrame
     gridded(meuse.grid) = TRUE            # promote to SpatialGridDataFrame
     image(meuse.grid["dist"], main = "Distance to river Meuse")
     data(meuse)
     coordinates(meuse) = c("x", "y")
     points(coordinates(meuse), pch = "+")
     data(Rlogo)
     d = dim(Rlogo)
     cellsize = abs(c(gt[2],gt[6]))
     cells.dim = c(d[1], d[2]) # c(d[2],d[1])
     cellcentre.offset = c(x = gt[1] + 0.5 * cellsize[1], y = gt[4] - (d[2] - 0.5) * abs(cellsize[2]))
     grid = GridTopology(cellcentre.offset, cellsize, cells.dim)
     df = as.vector(Rlogo[,,1])
     for (band in 2:d[3]) df = cbind(df, as.vector(Rlogo[,,band]))
     df = as.data.frame(df)
     names(df) = paste("band", 1:d[3], sep="")
     Rlogo <- SpatialGridDataFrame(grid = grid, data = df)
     summary(Rlogo)
     image(Rlogo, red="band1", green="band2", blue="band3")

