pal2SpatialPolygons         package:maptools         R Documentation

_M_a_k_i_n_g _S_p_a_t_i_a_l_P_o_l_y_g_o_n_s _o_b_j_e_c_t_s _f_r_o_m _R_A_r_c_I_n_f_o _i_n_p_u_t

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

     This function is used in making SpatialPolygons objects from
     RArcInfo input.

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

     pal2SpatialPolygons(arc, pal, IDs, dropPoly1=TRUE,
      proj4string=CRS(as.character(NA)))

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

     IDs: Unique character ID values for each output Polygons object;
          the input IDs can be an integer or character vector with
          duplicates, where the duplicates will be combined as a single
          output Polygons object

proj4string: Object of class '"CRS"'; holding a valid proj4 string

     arc: Object returned by 'get.arcdata'

     pal: Object returned by 'get.paldata'

dropPoly1: Should the first polygon in the AVC or e00 data be dropped;
          the first polygon is typically the compound boundary of the
          whole dataset, and can be detected by looking at the relative
          lengths of the list components in the second component of
          pal, which are the numbers of arcs making up the boundary of
          each polygon

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

     The functions return a SpatialPolygons object

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

     Roger Bivand

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

     nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], ID="FIPS")
     plot(nc1)
     text(coordinates(nc1), labels=sapply(slot(nc1, "polygons"),
      function(i) slot(i, "ID")), cex=0.6)
     library(maps)
     ncmap <- map("county", "north carolina", fill=TRUE, col="transparent",
      plot=FALSE)
     IDs <- sapply(strsplit(ncmap$names, "[,:]"), function(x) x[2])
     nc2 <- map2SpatialPolygons(ncmap, IDs)
     plot(nc2)
     text(coordinates(nc2), labels=sapply(slot(nc2, "polygons"),
      function(i) slot(i, "ID")), cex=0.6)
     library(RArcInfo)
     td <- tempdir()
     tmpcover <- paste(td, "nc", sep="/")
     if (!file.exists(tmpcover)) e00toavc(system.file("share/co37_d90.e00",
      package="maptools")[1], tmpcover)
     arc <- get.arcdata(td, "nc")
     pal <- get.paldata(td, "nc")
     pat <- get.tabledata(paste(td, "info", sep="/"), "NC.PAT")
     sapply(pal[[2]], function(x) length(x[[1]]))
     IDs <- paste(pat$ST[-1], pat$CO[-1], sep="")
     nc3 <- pal2SpatialPolygons(arc, pal, IDs=IDs)
     plot(nc3)
     text(coordinates(nc3), labels=sapply(slot(nc3, "polygons"),
      function(i) slot(i, "ID")), cex=0.6)

