SpatialPolygonsDataFrame-class      package:sp      R Documentation

_C_l_a_s_s "_S_p_a_t_i_a_l_P_o_l_y_g_o_n_s_D_a_t_a_F_r_a_m_e"

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

     class to hold polygons with attributes

_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 to the function
     SpatialPolygonsDataFrame

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

     '_d_a_t_a': Object of class '"data.frame"'; attribute table 

     '_p_o_l_y_g_o_n_s': Object of class '"list"'; see SpatialPolygons-class 

     '_p_l_o_t_O_r_d_e_r': Object of class '"integer"'; see
          SpatialPolygons-class 

     '_b_b_o_x': Object of class '"matrix"'; see Spatial-class

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

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

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

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

     No methods defined with class "SpatialPolygonsDataFrame" in the
     signature.

_N_o_t_e:

     'SpatialPolygonsDataFrame' with default ID matching checks the
     data frame row names against the Polygons ID slots. They must then
     agree with each other, and be unique (no Polygons objects can
     share IDs); the data frame rows will be re-ordered if needed to
     match the Polygons IDs.

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

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

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

     SpatialPolygons-class

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

     data(ncshp)
     nc1 <- as.SpatialPolygons.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS))
     df <- nc.shp$att.data
     rownames(df) <- as.character(nc.shp$att.data$FIPS)
     identical(rownames(df), getSpPPolygonsIDSlots(nc1))
     ncSpPDF <- SpatialPolygonsDataFrame(nc1, df)
     names(as(ncSpPDF, "data.frame"))
     identical(rownames(as(ncSpPDF, "data.frame")), getSpPPolygonsIDSlots(ncSpPDF))
     rrt <- as(ncSpPDF, "data.frame")$SID74/as(ncSpPDF, "data.frame")$BIR74
     brks <- quantile(rrt, seq(0,1,1/7))
     cols <- grey((length(brks):2)/length(brks))
     dens <- (2:length(brks))*3
     plot.SpatialPolygons(ncSpPDF, col=cols[findInterval(rrt, brks, all.inside=TRUE)])
     plot.SpatialPolygons(ncSpPDF, density=dens[findInterval(rrt, brks, all.inside=TRUE)])

