| coerce-sp-methods | R Documentation |
"SpatialPolygons" to "owin"Package polyCub implements coerce-methods
(as(object, Class)) to convert
"SpatialPolygons"
(or "Polygons"
or "Polygon")
of package sp
to "owin"
of package spatstat.geom.
They are also available as as.owin.* functions to support
polyCub.midpoint.
as.owin.SpatialPolygons(W, ...)
as.owin.Polygons(W, ...)
as.owin.Polygon(W, ...)
W |
an object of class |
... |
further arguments passed to |
The polygon(s) as an
"owin" object.
Sebastian Meyer
xylist
diamond <- list(x = c(1,2,1,0), y = c(1,2,3,2)) # anti-clockwise
diamond.sp <- sp::Polygon(lapply(diamond, rev)) # clockwise
diamond.Ps <- sp::Polygons(list(diamond.sp), ID = "my diamond")
diamond.SpPs <- sp::SpatialPolygons(list(diamond.Ps))
if (require("spatstat.geom")) {
diamond.owin <- owin(poly = diamond)
diamond.owin_from_Polygon <- as.owin(diamond.sp)
stopifnot(all.equal(diamond.owin, diamond.owin_from_Polygon))
## also for "Polygons" and "SpatialPolygons", using S3 or S4 methods:
stopifnot(identical(diamond.owin, as.owin(diamond.Ps)))
stopifnot(identical(diamond.owin, as(diamond.SpPs, "owin")))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.