File: polygons.Rd

package info (click to toggle)
r-cran-sp 1:0.9-66-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,696 kB
  • ctags: 123
  • sloc: ansic: 1,475; sh: 6; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
\name{polygons}
\alias{polygons<-}
\alias{polygons}

\title{ sets spatial coordinates to create spatial data, or retrieves
spatial coordinates }
\description{ sets spatial coordinates to create spatial data, or retrieves
spatial coordinates }
\usage{
	polygons(obj)
	polygons(object) <- value
}
\arguments{
\item{obj}{ object of class "SpatialPolygons" or "SpatialPolygonsDataFrame" }
\item{object}{ object of class "data.frame" }
\item{value}{ object of class "SpatialPolygons" }
}
\value{ polygons returns the SpatialPolygons of obj; polygons<- promotes a
data.frame to a SpatialPolygonsDataFrame object }

\examples{
%data(ncshp)
%nc1 <- as.SpatialPolygons.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS))
%df <- nc.shp$att.data
%rownames(df) <- df$FIPS
%polygons(df) <- nc1
%class(df)
grd <- GridTopology(c(1,1), c(1,1), c(10,10))
polys <- as.SpatialPolygons.GridTopology(grd)
centroids <- coordinates(polys)
x <- centroids[,1]
y <- centroids[,2]
z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
df <- data.frame(x=x, y=y, z=z, row.names=sapply(slot(polys, "polygons"), function(i) slot(i, "ID")))
polygons(df) <- polys
class(df)
summary(df)
}
\keyword{manip}