SpatialPolygonsDataFrame-class {sp}R Documentation

Class "SpatialPolygonsDataFrame"

Description

class to hold polygons with attributes

Objects from the Class

Objects can be created by calls to the function SpatialPolygonsDataFrame

Slots

data:
Object of class "data.frame"; attribute table
polygons:
Object of class "list"; see SpatialPolygons-class
plotOrder:
Object of class "integer"; see SpatialPolygons-class
bbox:
Object of class "matrix"; see Spatial-class
proj4string:
Object of class "CRS"; see CRS-class

Extends

Class "SpatialPolygons", directly. Class "Spatial", by class "SpatialPolygons".

Methods

No methods defined with class "SpatialPolygonsDataFrame" in the signature.

Note

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.

Author(s)

References

See Also

SpatialPolygons-class

Examples

data(ncshp)
nc1 <- as.SpatialPolygons.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS))
df <- nc.shp$att.data
rownames(df) <- as.character(nc.shp$att.data$FIPS)
identical(rownames(df), getSpPPolygonsIDSlots(nc1))
ncSpPDF <- SpatialPolygonsDataFrame(nc1, df)
names(as(ncSpPDF, "data.frame"))
identical(rownames(as(ncSpPDF, "data.frame")), getSpPPolygonsIDSlots(ncSpPDF))
rrt <- as(ncSpPDF, "data.frame")$SID74/as(ncSpPDF, "data.frame")$BIR74
brks <- quantile(rrt, seq(0,1,1/7))
cols <- grey((length(brks):2)/length(brks))
dens <- (2:length(brks))*3
plot.SpatialPolygons(ncSpPDF, col=cols[findInterval(rrt, brks, all.inside=TRUE)])
plot.SpatialPolygons(ncSpPDF, density=dens[findInterval(rrt, brks, all.inside=TRUE)])

[Package sp version 0.7-12 Index]