Learn R Programming

sp (version 1.4-2)

as.SpatialPolygons.PolygonsList: Making SpatialPolygons objects

Description

This function is used in making SpatialPolygons objects from other formats.

Usage

as.SpatialPolygons.PolygonsList(Srl, proj4string=CRS(as.character(NA)))


Arguments

Srl

A list of Polygons objects

proj4string

Object of class "CRS"; holding a valid proj4 string

Value

The functions return a SpatialPolygons object

Examples

Run this code
# NOT RUN {
<!-- %\dontrun{ -->
# }
# NOT RUN {
<!-- %library(maptools) -->
# }
# NOT RUN {
<!-- %nc.shp <- read.shape(system.file("shapes/sids.shp", package="maptools")[1]) -->
# }
# NOT RUN {
<!-- %} -->
# }
# NOT RUN {
<!-- %data(ncshp) -->
# }
# NOT RUN {
<!-- %nc1 <- as.SpatialPolygons.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS)) -->
# }
# NOT RUN {
<!-- %plot(nc1) -->
# }
# NOT RUN {
<!-- %invisible(text(coordinates(nc1), labels=getSpPPolygonsIDSlots(nc1), cex=0.6)) -->
# }
# NOT RUN {
<!-- %\dontrun{ -->
# }
# NOT RUN {
<!-- %library(maps) -->
# }
# NOT RUN {
<!-- %ncmap <- map("county", "north carolina", fill=TRUE, col="transparent", plot=FALSE) -->
# }
# NOT RUN {
<!-- %} -->
# }
# NOT RUN {
<!-- %data(ncmap) -->
# }
# NOT RUN {
<!-- %IDs <- sapply(strsplit(ncmap$names, "[,:]"), function(x) x[2]) -->
# }
# NOT RUN {
<!-- %nc2 <- as.SpatialPolygons.map(ncmap, IDs) -->
# }
# NOT RUN {
<!-- %plot(nc2) -->
# }
# NOT RUN {
<!-- %invisible(text(coordinates(nc2), labels=getSpPPolygonsIDSlots(nc2), cex=0.6)) -->
# }
# NOT RUN {
<!-- %\dontrun{ -->
# }
# NOT RUN {
<!-- %library(RArcInfo) -->
# }
# NOT RUN {
<!-- %fl <- "http://www.census.gov/geo/cob/bdy/co/co90e00/co37_d90_e00.zip" -->
# }
# NOT RUN {
<!-- %download.file(fl, "co37_d90_e00.zip") -->
# }
# NOT RUN {
<!-- %e00 <- zip.file.extract("co37_d90.e00", "co37_d90_e00.zip") -->
# }
# NOT RUN {
<!-- %e00toavc(e00, "nc") -->
# }
# NOT RUN {
<!-- %arc <- get.arcdata(".", "nc") -->
# }
# NOT RUN {
<!-- %pal <- get.paldata(".", "nc") -->
# }
# NOT RUN {
<!-- %pat <- get.tabledata("info", "NC.PAT") -->
# }
# NOT RUN {
<!-- %} -->
# }
# NOT RUN {
<!-- %data(co37_d90_arc) -->
# }
# NOT RUN {
<!-- %data(co37_d90_pal) -->
# }
# NOT RUN {
<!-- %sapply(pal[[2]], function(x) length(x[[1]])) -->
# }
# NOT RUN {
<!-- %data(co37_d90_pat) -->
# }
# NOT RUN {
<!-- %IDs <- paste(pat$ST[-1], pat$CO[-1], sep="") -->
# }
# NOT RUN {
<!-- %nc3 <- as.SpatialPolygons.pal(arc, pal, IDs=IDs) -->
# }
# NOT RUN {
<!-- %plot(nc3) -->
# }
# NOT RUN {
<!-- %invisible(text(coordinates(nc3), labels=sapply(slot(nc3, "polygons"), function(i) slot(i, "ID")), cex=0.6)) -->
# }
# NOT RUN {
grd <- GridTopology(c(1,1), c(1,1), c(10,10))
polys <- as.SpatialPolygons.GridTopology(grd)
plot(polys)
text(coordinates(polys), labels=sapply(slot(polys, "polygons"), function(i) slot(i, "ID")), cex=0.6)
# }

Run the code above in your browser using DataLab