sp2tmap               package:maptools               R Documentation

_C_o_n_v_e_r_t _S_p_a_t_i_a_l_P_o_l_y_g_o_n_s _o_b_j_e_c_t _f_o_r _S_t_a_t_a _t_m_a_p _c_o_m_m_a_n_d

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

     The function converts a SpatialPolygons object for use with the
     Stata tmap command, by creating a data frame with the required
     columns.

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

     sp2tmap(SP)

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

      SP: a SpatialPolygons object

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

     a data frame with three columns: 

    \_ID: an integer vector of polygon identifiers in numeric order

     \_X: numeric x coordinate

     \_Y: numeric y coordinate

     and an 'ID_n' attribute with the named polygon identifiers

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

     Roger Bivand

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

     <URL: http://www.stata.com/search.cgi?query=tmap>

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

     'write.dta'

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

     ## Not run: 
     xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
      IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
     plot(xx, border="blue", axes=TRUE, las=1)
     tmapdf <- sp2tmap(as(xx, "SpatialPolygons"))
     write.dta(tmapdf, file="NCmap.dta", version=7)
     NCdf <- as(xx, "data.frame")
     NCdf$ID_n <- attr(tmapdf, "ID_names")
     write.dta(NCdf, file="NC.dta", version=7)
     ## End(Not run)

