SpatialPolygonsDataFrame-class {sp} | R Documentation |
class to hold polygons with attributes
Objects can be created by calls to the function SpatialPolygonsDataFrame
data
:"data.frame"
; attribute table polygons
:"list"
; see SpatialPolygons-class plotOrder
:"integer"
; see SpatialPolygons-class bbox
:"matrix"
; see Spatial-classproj4string
:"CRS"
; see CRS-class
Class "SpatialPolygons"
, directly.
Class "Spatial"
, by class "SpatialPolygons"
.
Methods defined with class "SpatialPolygonsDataFrame" in the signature:
signature(x = "SpatialPolygonsDataFrame")
: select subset of (sets of) polygons; NAs are not permitted in the row index\signature(object = "SpatialPolygonsDataFrame")
: summarize object
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.
grd <- GridTopology(c(1,1), c(1,1), c(10,10)) polys <- as.SpatialPolygons.GridTopology(grd) centroids <- getSpPPolygonsLabptSlots(polys) x <- centroids[,1] y <- centroids[,2] z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x ex_1.7 <- SpatialPolygonsDataFrame(polys, data=data.frame(x=x, y=y, z=z, row.names=getSpPPolygonsIDSlots(polys))) brks <- quantile(z, seq(0,1,1/7)) cols <- grey((length(brks):2)/length(brks)) dens <- (2:length(brks))*3 plot(ex_1.7, col=cols[findInterval(z, brks, all.inside=TRUE)]) plot(ex_1.7, density=dens[findInterval(z, brks, all.inside=TRUE)])