File: geom.Rd

package info (click to toggle)
r-cran-raster 3.6-31-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,300 kB
  • sloc: cpp: 2,367; ansic: 1,572; sh: 13; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,725 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
\name{geom}

\docType{methods}

\alias{geom}
\alias{geom,SpatialPolygons-method}
\alias{geom,SpatialLines-method}
\alias{geom,SpatialPoints-method}
\alias{geom,data.frame-method}


\title{Get the coordinates of a vector type Spatial* object}

\description{
Extract the coordinates of a Spatial object
}

\usage{
\S4method{geom}{SpatialPolygons}(x, sepNA=FALSE, ...)
\S4method{geom}{SpatialLines}(x, sepNA=FALSE, ...)
\S4method{geom}{SpatialPoints}(x, ...)
\S4method{geom}{data.frame}(x, d, gt, crs, ...)
}

\arguments{
  \item{x}{SpatialPolygons*, SpatialLines*, or SpatialPoints* object; or a data.frame}
  \item{sepNA}{logical. If \code{TRUE}, geometries are separated by a row with \code{NA} values}
  \item{...}{additional arguments, none implemented}
  \item{d}{data.frame that matches the number of objects in data.frame \code{x}}
  \item{gt}{character. geometry type. Must be one of "polygons", "lines", "points"}
  \item{crs}{character. PROJ.4 crs string}  
}


\value{
Matrix with 6, (5 SpatialLines), or 3 (SpatialPoints) columns. object (sequential object number) part (sequential part number within the object; not for SpatialPoints), cump (cumulative part number; not for SpatialPoints), hole (is this a hole or not; only for SpatialPolygons), x (x coordinate or longitude), y (y coordinate or latitude)
}

\seealso{ \code{\link[sp]{coordinates}}, \code{\link[sp:geometry-methods]{geometry}} }


\examples{
p <- readRDS(system.file("external/lux.rds", package="raster"))
x <- geom(p)
head(x)
	
# and back to a SpatialPolygonsDataFrame	
x <- data.frame(x)
sp <- as(x, "SpatialPolygons")
crs(sp) <- crs(p)
spdf <- SpatialPolygonsDataFrame(sp, data.frame(p), match.ID=FALSE)
}

\keyword{methods}
\keyword{spatial}