| 1 |
\name{SpatialPolygons} |
| 2 |
\alias{SpatialPolygons} |
| 3 |
\alias{SpatialPolygonsDataFrame} |
| 4 |
\alias{Polygon} |
| 5 |
\alias{Polygons} |
| 6 |
\alias{getSpatialPolygonsLabelPoints} |
| 7 |
\title{ create objects of class SpatialPolygons or SpatialPolygonsDataFrame} |
| 8 |
\description{ create objects of class \code{SpatialPolygons} or \code{SpatialPolygonsDataFrame} from |
| 9 |
lists of \code{Polygons} objects and \code{data.frame}s} |
| 10 |
\usage{ |
| 11 |
Polygon(coords, hole=as.logical(NA)) |
| 12 |
Polygons(srl, ID) |
| 13 |
SpatialPolygons(Srl, pO, proj4string=CRS(as.character(NA))) |
| 14 |
SpatialPolygonsDataFrame(Sr, data, match.ID = TRUE) |
| 15 |
getSpatialPolygonsLabelPoints(SP) |
| 16 |
|
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{coords}{2-column numeric matrix with coordinates; first point (row) should |
| 20 |
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} |
| 21 |
\item{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} |
| 22 |
\item{proj4string}{ projection string of class \link{CRS-class}} |
| 23 |
\item{srl}{list with \link{Polygon-class} objects} |
| 24 |
\item{ID}{character vector of length one with identifier} |
| 25 |
\item{Srl}{ list with objects of class \link{Polygons-class}} |
| 26 |
\item{pO}{ integer vector; plotting order; if missing in reverse order of Polygons area } |
| 27 |
\item{Sr}{ object of class \link{SpatialPolygons-class}} |
| 28 |
\item{data}{ object of class \code{data.frame}; the number of rows in \code{data} should equal the number of \link{Polygons-class} objects in \code{Sr}} |
| 29 |
\item{match.ID}{logical: (default TRUE): match SpatialPolygons |
| 30 |
member Polygons ID slot values with data frame row names, and |
| 31 |
re-order the data frame rows if necessary. If character: indicates |
| 32 |
the column in \code{data} with Polygons IDs to match} |
| 33 |
\item{SP}{object of class \link{SpatialPolygons-class}} |
| 34 |
} |
| 35 |
|
| 36 |
\details{ |
| 37 |
In \code{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 \code{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. |
| 38 |
|
| 39 |
The class definitions used for polygons in \pkg{sp} do not accord with those of |
| 40 |
the simple features specification of the Open Geospatial Consortium. The \pkg{rgeos} package, an interface to Geometry Engine -- Open Source (GEOS), uses this |
| 41 |
specification, in which each hole (interior ring) must be associated with |
| 42 |
its containing exterior ring. In order to avoid introducing incompatible |
| 43 |
changes into the class definition of Polygons objects, a comment has been |
| 44 |
added as a single character string to each such object. Here we can trust |
| 45 |
the data source to assign the hole status correctly, and use round-trip coercion to \code{sf} to add such comments to each Polygons member of |
| 46 |
the polygons slot of this SpatialPolygons object. Exterior rings are coded |
| 47 |
zero, while interior rings are coded with the 1-based index of the |
| 48 |
exterior ring to which they belong. SpatialPolygons objects created by reading using \code{sf} have the comments set on input, as OGR also uses SFS. |
| 49 |
|
| 50 |
Refer to Bivand et al. (2013), pages 47-48 and 132-133 for a further discussion. |
| 51 |
} |
| 52 |
|
| 53 |
\value{ |
| 54 |
\code{Polygon} returns an object of class \code{Polygon}; |
| 55 |
\code{Polygons} returns an object of class \code{Polygons}; |
| 56 |
\code{SpatialPolygons} returns object of class \code{SpatialPolygons}; |
| 57 |
\code{SpatialPolygonsDataFrame} returns object of class \code{SpatialPolygonsDataFrame} |
| 58 |
\code{getSpatialPolygonsLabelPoints} returns an object of class |
| 59 |
\code{SpatialPoints} with label points. |
| 60 |
} |
| 61 |
\seealso{ \link{SpatialPolygons-class}, \link{SpatialPolygonsDataFrame-class} } |
| 62 |
|
| 63 |
\references{Roger Bivand, Edzer Pebesma and Virgilio Gomez-Rubio, 2013. Applied spatial data analysis with R, Second edition. Springer, NY. \url{https://asdar-book.org/}} |
| 64 |
|
| 65 |
\keyword{manip} |