Learn R Programming

sp (version 2.1-2)

SpatialPolygons: create objects of class SpatialPolygons or SpatialPolygonsDataFrame

Description

create objects of class SpatialPolygons or SpatialPolygonsDataFrame from lists of Polygons objects and data.frames

Usage

Polygon(coords, hole=as.logical(NA))
Polygons(srl, ID)
SpatialPolygons(Srl, pO, proj4string=CRS(as.character(NA)))
SpatialPolygonsDataFrame(Sr, data, match.ID = TRUE)
getSpatialPolygonsLabelPoints(SP)

Value

Polygon returns an object of class Polygon; Polygons returns an object of class Polygons; SpatialPolygons returns object of class SpatialPolygons; SpatialPolygonsDataFrame returns object of class SpatialPolygonsDataFrame

getSpatialPolygonsLabelPoints returns an object of class SpatialPoints with label points.

Arguments

coords

2-column numeric matrix with coordinates; first point (row) should equal last coordinates (row); if the hole argument is not given, the status of the polygon as a hole or an island will be taken from the ring direction, with clockwise meaning island, and counter-clockwise meaning hole

hole

logical value for setting polygon as hole or not; if the hole argument is not given, the status of the polygon as a hole or an island will be taken from the ring direction, with clockwise meaning island, and counter-clockwise meaning hole

proj4string

projection string of class CRS-class

srl

list with Polygon-class objects

ID

character vector of length one with identifier

Srl

list with objects of class Polygons-class

pO

integer vector; plotting order; if missing in reverse order of Polygons area

Sr

object of class SpatialPolygons-class

data

object of class data.frame; the number of rows in data should equal the number of Polygons-class objects in Sr

match.ID

logical: (default TRUE): match SpatialPolygons member Polygons ID slot values with data frame row names, and re-order the data frame rows if necessary. If character: indicates the column in data with Polygons IDs to match

SP

object of class SpatialPolygons-class

Details

In Polygon, if the hole argument is not given, the status of the polygon as a hole or an island will be taken from the ring direction, with clockwise meaning island, and counter-clockwise meaning hole. In Polygons, if all of the member Polygon objects are holes, the largest by area will be converted to island status. Until 2010-04-17, version 0.9-61, the area of this converted object was erroneously left at its hole value of zero. Thanks to Patrick Giraudoux for spotting the bug.

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 round-trip coercion to sf 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 sf have the comments set on input, as OGR also uses SFS.

Refer to Bivand et al. (2013), pages 47-48 and 132-133 for a further discussion.

References

Roger Bivand, Edzer Pebesma and Virgilio Gomez-Rubio, 2013. Applied spatial data analysis with R, Second edition. Springer, NY. https://asdar-book.org/

See Also

SpatialPolygons-class, SpatialPolygonsDataFrame-class