Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

geom

Get the coordinates of a vector type Spatial* object


Description

Extract the coordinates of a Spatial object

Usage

## S4 method for signature 'SpatialPolygons'
geom(x, sepNA=FALSE, ...)
## S4 method for signature 'SpatialLines'
geom(x, sepNA=FALSE, ...)
## S4 method for signature 'SpatialPoints'
geom(x, ...)
## S4 method for signature 'data.frame'
geom(x, d, gt, crs, ...)

Arguments

x

SpatialPolygons*, SpatialLines*, or SpatialPoints* object; or a data.frame

sepNA

logical. If TRUE, geometries are separated by a row with NA values

...

additional arguments, none implemented

d

data.frame that matches the number of objects in data.frame x

gt

character. geometry type. Must be one of "polygons", "lines", "points"

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)

See Also

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)

raster

Geographic Data Analysis and Modeling

v3.4-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Jacob van Etten [ctb], Michael Sumner [ctb], Joe Cheng [ctb], Dan Baston [ctb], Andrew Bevan [ctb], Roger Bivand [ctb], Lorenzo Busetto [ctb], Mort Canty [ctb], Ben Fasoli [ctb], David Forrest [ctb], Aniruddha Ghosh [ctb], Duncan Golicher [ctb], Josh Gray [ctb], Jonathan A. Greenberg [ctb], Paul Hiemstra [ctb], Kassel Hingee [ctb], Institute for Mathematics Applied Geosciences [cph], Charles Karney [ctb], Matteo Mattiuzzi [ctb], Steven Mosher [ctb], Babak Naimi [ctb], Jakub Nowosad [ctb], Edzer Pebesma [ctb], Oscar Perpinan Lamigueiro [ctb], Etienne B. Racine [ctb], Barry Rowlingson [ctb], Ashton Shortridge [ctb], Bill Venables [ctb], Rafael Wueest [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.