sp (version 1.0-15)

SpatialPolygons-class: Class "SpatialPolygons"

Description

class to hold polygon topology (without attributes)

Arguments

Objects from the Class

Objects can be created by calls to the function SpatialPolygons

Extends

Class "Spatial", directly.

Details

The plot method for spatial polygons takes the following arguments: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] The options for usePolypath and rule may be retrieved with get_Polypath (default TRUE on package load) and get_PolypathRule (default winding on package load), and set with set_Polypath and set_PolypathRule

The class definitions used for polygons in sp do not accord with those of the simple features specification of the Open Geospatial Consortium. The rgeos package, an interface to Geometry Engine -- Open Source (GEOS), uses this specification, in which each hole (interior ring) must be associated with its containing exterior ring. In order to avoid introducing incompatible changes into the class definition of Polygons objects, a comment has been added as a single character string to each such object. Here we can trust the data source to assign the hole status correctly, and use the simple function createSPComment to add such comments to each Polygons member of the polygons slot of this SpatialPolygons object. Exterior rings are coded zero, while interior rings are coded with the 1-based index of the exterior ring to which they belong. SpatialPolygons objects created by reading using readOGR from rgdal have the comments set on input, as OGR also uses SFS.

See Also

SpatialPolygons

Examples

Run this code
# simple example, from vignette("sp"):
Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)

Srs1 = Polygons(list(Sr1), "s1")
Srs2 = Polygons(list(Sr2), "s2")
Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
plot(SpP, col = 1:3, pbg="white")

grd <- GridTopology(c(1,1), c(1,1), c(10,10))
polys <- as(grd, "SpatialPolygons")
plot(polys)
text(coordinates(polys), labels=row.names(polys))

Run the code above in your browser using DataLab