polygons                 package:sp                 R Documentation

_s_e_t_s _s_p_a_t_i_a_l _c_o_o_r_d_i_n_a_t_e_s _t_o _c_r_e_a_t_e _s_p_a_t_i_a_l _d_a_t_a, _o_r _r_e_t_r_i_e_v_e_s
_s_p_a_t_i_a_l _c_o_o_r_d_i_n_a_t_e_s

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

     sets spatial coordinates to create spatial data, or retrieves
     spatial coordinates

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

             polygons(obj)
             polygons(object) <- value

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

     obj: object of class "SpatialPolygons" or
          "SpatialPolygonsDataFrame" 

  object: object of class "data.frame" 

   value: object of class "SpatialPolygons" 

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

     polygons returns the SpatialPolygons of obj; polygons<- promotes a
     data.frame to a SpatialPolygonsDataFrame object

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

     grd <- GridTopology(c(1,1), c(1,1), c(10,10))
     polys <- as.SpatialPolygons.GridTopology(grd)
     centroids <- coordinates(polys)
     x <- centroids[,1]
     y <- centroids[,2]
     z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
     df <- data.frame(x=x, y=y, z=z, row.names=sapply(slot(polys, "polygons"), function(i) slot(i, "ID")))
     polygons(df) <- polys
     class(df)
     summary(df)

