geom {raster} | R Documentation |
Extract the coordinates of a Spatial object
## S4 method for signature 'SpatialPolygons' geom(x, sepNA=FALSE, ...)
x |
SpatialPolygons*, SpatialLines*, or SpatialPoints* object |
sepNA |
logical. If |
... |
additional arguments, none implemented |
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)
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)