SpatialPixelsDataFrame-class       package:sp       R Documentation

_C_l_a_s_s "_S_p_a_t_i_a_l_P_i_x_e_l_s_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
     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,
     "SpatialPixelsDataFrame")', where 'x' is of class
     SpatialPointsDataFrame-class, or by importing through rgdal.  
     Ordered full grids are stored instead or unordered non-NA cells;

_S_l_o_t_s:

     '_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 

     '_g_r_i_d': see GridTopology-class; grid parameters 

     '_g_r_i_d._i_n_d_e_x': integer; index of points in the list to points in
          the full (ordered) grid. x cycles fastest; all coordinates
          increase from low to hight except y, which decreases from
          high to low 

     '_d_a_t_a': Object of class AttributeList-class containing the
          attribute data 

_E_x_t_e_n_d_s:

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

_M_e_t_h_o_d_s:

     _c_o_o_r_d_i_n_a_t_e_s 'signature(x = "SpatialPixelsDataFrame")': retrieves
          (and calculates!) coordinates 

     [ 'signature(x = "SpatialPixelsDataFrame")': selects row(s) and/or
          attribute(s), and returns an object of class
          'SpatialPixelsDataFrame'; rows refer here to the pixel
          numbers, not grid lines. For selecting a square block in a
          grid, coerce to a SpatialGridDataFrame-class first, and use
          '[' on that object

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

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

     _a_s._m_a_t_r_i_x 'signature(x = "SpatialPixelsDataFrame")': coerce to
          matrix 

_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:

     'SpatialPixels-class', which does not contain the attribute data

_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
     meuse.grid[["idist"]] = 1 - meuse.grid[["dist"]] # assigns new attribute
     image(meuse.grid["idist"]) # note the single [

     # 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
     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)

