as.SpatialPolygons.PolygonsList      package:sp      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

_D_e_s_c_r_i_p_t_i_o_n:

     These functions show how SpatialPolygons objects may be built from
     data from shapefiles, from the maps package, and from ArcInfo e00
     files.

_U_s_a_g_e:

     as.SpatialPolygons.PolygonsList(Srl, proj4string=CRS(as.character(NA))
     as.SpatialPolygons.Shapes(shapes, IDs, proj4string=CRS(as.character(NA)))
     as.SpatialPolygons.map(map, IDs, proj4string=CRS(as.character(NA)))
     as.SpatialPolygons.pal(arc, pal, IDs, dropPoly1=TRUE, proj4string=CRS(as.character(NA)))

_A_r_g_u_m_e_n_t_s:

     Srl: A list of Polygons objects

  shapes: The Shapes component of a Map object as read by 'read.shape'

     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

     map: Object returned by 'map' containing polygon boundaries

     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:

     ## Not run: 
     library(maptools)
     nc.shp <- read.shape(system.file("shapes/sids.shp", package="maptools")[1])
     ## End(Not run)
     data(ncshp)
     nc1 <- as.SpatialPolygons.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS))
     plotSpatialPolygons(nc1)
     invisible(text(getSpPPolygonsLabptSlots(nc1), labels=getSpPPolygonsIDSlots(nc1), cex=0.6))
     ## Not run: 
     library(maps)
     ncmap <- map("county", "north carolina", fill=TRUE, col="transparent", plot=FALSE)
     ## End(Not run)
     data(ncmap)
     IDs <- sapply(strsplit(ncmap$names, "[,:]"), function(x) x[2])
     nc2 <- as.SpatialPolygons.map(ncmap, IDs)
     plotSpatialPolygons(nc2)
     invisible(text(getSpPPolygonsLabptSlots(nc2), labels=getSpPPolygonsIDSlots(nc2), cex=0.6))
     ## Not run: 
     library(RArcInfo)
     fl <- "http://www.census.gov/geo/cob/bdy/co/co90e00/co37_d90_e00.zip"
     download.file(fl, "co37_d90_e00.zip")
     e00 <- zip.file.extract("co37_d90.e00", "co37_d90_e00.zip")
     e00toavc(e00, "nc")
     arc <- get.arcdata(".", "nc")
     pal <- get.paldata(".", "nc")
     pat <- get.tabledata("info", "NC.PAT")
     ## End(Not run)
     data(co37_d90_arc)
     data(co37_d90_pal)
     sapply(pal[[2]], function(x) length(x[[1]]))
     data(co37_d90_pat)
     IDs <- paste(pat$ST[-1], pat$CO[-1], sep="")
     nc3 <- as.SpatialPolygons.pal(arc, pal, IDs=IDs)
     plotSpatialPolygons(nc3)
     invisible(text(getSpPPolygonsLabptSlots(nc3), labels=getSpPPolygonsIDSlots(nc3), cex=0.6))

