Debian Codegraph @

man/SpatialPolygons-class.Rd

raw
1 \name{SpatialPolygons-class}
2 \docType{class}
3 \alias{SpatialPolygons-class}
4 \alias{[,SpatialPolygons-method}
5 \alias{as.data.frame.SpatialPolygons}
6 \alias{as.SpatialPolygonsDataFrame.SpatialPolygons}
7 \alias{coerce,SpatialPolygons,SpatialPolygonsDataFrame-method}
8 \alias{plot,SpatialPolygons,missing-method}
9 \alias{summary,SpatialPolygons-method}
10 \alias{rbind.SpatialPolygons}
11 \alias{coerce,Polygons,Lines-method}
12 \alias{coerce,SpatialPolygons,SpatialLines-method}
13 \alias{coerce,deldir,SpatialPolygons-method}
14 \alias{row.names.SpatialPolygons}
15 \alias{get_Polypath}
16 \alias{set_Polypath}
17 \alias{get_PolypathRule}
18 \alias{set_PolypathRule}
19
20
21 \title{Class "SpatialPolygons"}
22 \description{ class to hold polygon topology (without attributes) }
23 \section{Objects from the Class}{
24 Objects can be created by calls to the function \link{SpatialPolygons}
25 }
26 \section{Slots}{
27 \describe{
28 \item{\code{polygons}:}{Object of class \code{"list"}; list elements are
29 all of class \link{Polygons-class}}
30 \item{\code{plotOrder}:}{Object of class \code{"integer"}; integer array
31 giving the order in which objects should be plotted }
32 \item{\code{bbox}:}{Object of class \code{"matrix"}; see \link{Spatial-class} }
33 \item{\code{proj4string}:}{Object of class \code{"CRS"}; see \link{CRS-class}}
34 }
35 }
36 \section{Extends}{
37 Class \code{"Spatial"}, directly.
38 }
39 \section{Methods}{
40 Methods defined with class "SpatialPolygons" in the signature:
41 \describe{
42 \item{[}{\code{signature(obj = "SpatialPolygons")}: select subset of (sets of) polygons; NAs are not permitted in the row index}
43 \item{plot}{\code{signature(x = "SpatialPolygons", y = "missing")}:
44 plot polygons in SpatialPolygons object}
45 \item{summary}{\code{signature(object = "SpatialPolygons")}: summarize object}
46 \item{rbind}{\code{signature(object = "SpatialPolygons")}: rbind-like method}
47 }
48 }
49
50 \section{plot method arguments}{
51 The \code{plot} method for spatial polygons takes the following arguments:
52 \describe{
53 \item{x}{a SpatialPolygons object}
54 \item{col}{a vector of colour values}
55 \item{border}{default \code{par("fg")}; the colour to draw the border}
56 \item{add}{default FALSE; if TRUE, add to existing plot}
57 \item{xlim, ylim}{default NULL; ranges for the plotted \sQuote{x} and \sQuote{y} values}
58 \item{xpd}{default NULL; controls clipping, see \code{\link[graphics]{par}}}
59 \item{density}{default NULL; the density of shading lines, in lines per inch, see \code{\link[graphics]{polygon}}}
60 \item{angle}{default 45; the slope of shading lines, given as an angle in degrees (counter-clockwise), see \code{\link[graphics]{polygon}}}
61 \item{pbg}{default NULL, set to \code{par("bg")} by default \dQuote{transparent}; the colour to paint holes}
62 \item{axes}{default FALSE; draw axes}
63 \item{lty}{default \code{par("lty")}; border line type}
64 \item{...}{other arguments passed through}
65 \item{setParUsrBB}{default FALSE; see \code{\link{Spatial-class}} for further details}
66 \item{usePolypath}{default NULL to set from option value; use \code{\link[graphics]{polypath}} for hole-handling in plot}
67 \item{rule}{default NULL to set from option value; character value specifying the path fill mode, see \code{\link[graphics]{polypath}}}
68 }
69 The options for \code{usePolypath} and \code{rule} may be retrieved with \code{get_Polypath} (default TRUE on package load) and \code{get_PolypathRule} (default \dQuote{winding} on package load), and set with \code{set_Polypath} and \code{set_PolypathRule}
70
71 The class definitions used for polygons in \pkg{sp} do not accord with those of
72 the simple features specification of the Open Geospatial Consortium. The \pkg{rgeos} package, an interface to Geometry Engine -- Open Source (GEOS), uses this
73 specification, in which each hole (interior ring) must be associated with
74 its containing exterior ring. In order to avoid introducing incompatible
75 changes into the class definition of Polygons objects, a comment has been
76 added as a single character string to each such object. Here we can trust
77 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
78 the polygons slot of this SpatialPolygons object. Exterior rings are coded
79 zero, while interior rings are coded with the 1-based index of the
80 exterior ring to which they belong. SpatialPolygons objects created by reading using \code{sf} or \code{terra} have the comments set on input, as OGR also uses SFS.
81
82 Refer to Bivand et al. (2013), pages 47-48 and 132-133 for a further discussion.
83 }
84
85 \note{
86 \code{rbind} calls the function \code{\link{SpatialPolygons}}, where it is
87 checked that all IDs are unique. If \code{rbind}-ing \code{SpatialPolygons} without
88 unique IDs, it is possible to set the argument \code{makeUniqueIDs = TRUE}, although
89 it is preferred to change these explicitly with \code{\link{spChFIDs}}.
90 }
91
92
93 \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/}}
94
95 \author{ Roger Bivand }
96 \seealso{ \code{\link{SpatialPolygons}} }
97 \examples{
98 # simple example, from vignette("sp"):
99 Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
100 Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
101 Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
102 Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)
103
104 Srs1 = Polygons(list(Sr1), "s1")
105 Srs2 = Polygons(list(Sr2), "s2")
106 Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
107 SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
108 plot(SpP, col = 1:3, pbg="white")
109
110 grd <- GridTopology(c(1,1), c(1,1), c(10,10))
111 polys <- as(grd, "SpatialPolygons")
112 plot(polys)
113 text(coordinates(polys), labels=row.names(polys))
114 }
115 \keyword{classes}