SpatialGridDataFrame-class        package:sp        R Documentation

_C_l_a_s_s "_S_p_a_t_i_a_l_G_r_i_d_D_a_t_a_F_r_a_m_e" ~~~

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

     Class for spatial attributes that have spatial locations on a
     (full) regular grid.

_O_b_j_e_c_t_s _f_r_o_m _t_h_e _C_l_a_s_s:

     Objects can be created by calls of the form 'as(x,
     "SpatialGridDataFrame")', where 'x' is of class
     SpatialPixelsDataFrame-class, or by importing through rgdal.  
     Ordered full grids are stored instead or unordered non-NA cells;

_S_l_o_t_s:

     '_p_o_i_n_t_s': see SpatialPoints; points slot which is not actually
          filled with all coordinates (only with min/max) 

     '_g_r_i_d': see GridTopology-class; grid parameters 

     '_g_r_i_d._i_n_d_e_x': see SpatialPixels-class; this slot is of zero length
          for this class, as the grid is full 

     '_b_b_o_x': Object of class '"matrix"'; bounding box 

     '_p_r_o_j_4_s_t_r_i_n_g': Object of class '"CRS"'; projection 

     '_d_a_t_a': Object of class AttributeList-class, containing attribute
          data 

_E_x_t_e_n_d_s:

     Class '"SpatialGrid"', directly. Class '"Spatial"', by class
     '"SpatialGrid"'.

_M_e_t_h_o_d_s:

     _c_o_o_r_d_i_n_a_t_e_s 'signature(x = "SpatialGridDataFrame")': retrieves
          (and calculates!) coordinates 

     [ 'signature(x = "SpatialGridDataFrame")': selects rows, columns,
          and attributes; returns an object of class
          'SpatialGridDataFrame'

     [[ 'signature(x = "SpatialGridDataFrame")': retrieves an
          attribute, dropping everything  else (topology) 

     [[<- 'signature(x = "SpatialGridDataFrame")': assigns or replaces
          an attribute 

     _a_s._m_a_t_r_i_x 'signature(x = "SpatialGridDataFrame")': coerce to
          matrix 

     _c_b_i_n_d 'signature(...)': if arguments have identical topology,
          combine their attribute values

_N_o_t_e:

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

     Edzer J. Pebesma, e.pebesma@geo.uu.nl

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

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

     'SpatialGrid-class', which does not contain the attribute data,
     and 'SpatialPixelsDataFrame-class which holds possibly incomplete
     grids '

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

     data(meuse.grid) # only the non-missing valued cells
     coordinates(meuse.grid) = c("x", "y") # promote to SpatialPointsDataFrame
     gridded(meuse.grid) <- TRUE # promote to SpatialPixelsDataFrame
     x = as(meuse.grid, "SpatialGridDataFrame") # creates the full grid
     x[["idist"]] = 1 - x[["dist"]] # assigns new attribute
     image(x["idist"]) # note the single [ for attribute selection

     # toy example:
     df = data.frame(z = c(1:6,NA,8,9),
         xc = c(1,1,1,2,2,2,3,3,3),
         yc = c(rep(c(0, 1.5, 3),3)))
     coordinates(df) = ~xc+yc
     gridded(df) = TRUE
     df = as(df, "SpatialGridDataFrame") # to full grid
     image(df["z"])
     # draw labels to verify:
     cc = coordinates(df)
     z=df[["z"]]
     zc=as.character(z)
     zc[is.na(zc)]="NA"
     text(cc[,1],cc[,2],zc)

     # the following is weird, but illustrates the concept of row/col selection:
     fullgrid(meuse.grid) = TRUE
     image(meuse.grid)
     image(meuse.grid[20:70, 10:70, "dist"], add = TRUE, col = bpy.colors())

