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)
Run the code above in your browser using DataLab