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

coerce-sp-methods

Coerce "SpatialPolygons" to "owin"


Description

Package polyCub implements coerce-methods (as(object, Class)) to convert "SpatialPolygons" (or "Polygons" or "Polygon") to "owin". They are also available as as.owin.* functions to support polyCub.midpoint. Note that the maptools package contains an alternative implementation of coercion from "SpatialPolygons" to "owin" (and reverse); R will use the method that was loaded last.

Usage

as.owin.SpatialPolygons(W, ...)

as.owin.Polygons(W, ...)

as.owin.Polygon(W, ...)

Arguments

W

an object of class "SpatialPolygons", "Polygons", or "Polygon".

...

further arguments passed to owin.

Author(s)

Sebastian Meyer

See Also

Examples

if (require("spatstat.geom") && require("sp")) {
    diamond <- list(x = c(1,2,1,0), y = c(1,2,3,2))  # anti-clockwise
    diamond.owin <- owin(poly = diamond)
    diamond.sp <- Polygon(lapply(diamond, rev))      # clockwise
    stopifnot(identical(xylist(diamond.sp), list(diamond)))
    diamond.owin_from_sp <- as.owin(diamond.sp)
    stopifnot(all.equal(diamond.owin, diamond.owin_from_sp))

    ## similarly works for Polygons and SpatialPolygons
    diamond.Ps <- as(diamond.sp, "Polygons")
    stopifnot(identical(diamond.owin, as.owin(diamond.Ps)))
    diamond.SpPs <- SpatialPolygons(list(diamond.Ps))
    stopifnot(identical(xylist(diamond.SpPs), list(diamond)))
    stopifnot(identical(diamond.owin, as.owin(diamond.SpPs)))
}

polyCub

Cubature over Polygonal Domains

v0.8.0
GPL-2
Authors
Sebastian Meyer [aut, cre, trl] (<https://orcid.org/0000-0002-1791-9449>), Leonhard Held [ths], Michael Hoehle [ths]
Initial release
2021-01-26

We don't support your browser anymore

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