Description Usage Arguments Value Examples
View source: R/convertformats.R
Convert an ahull object from the alphahull package to a SpatialPolygonsDataFramefor wider use.
1 | ah2sp(x, increment = 360, rnd = 10, proj4string = CRS(as.character(NA)))
|
x |
An object of class ahull from the alphahull package |
increment |
A single numeric value for the number of increments with which to describe the circumference of a circle. |
rnd |
A single numeric value controlling the precision of the estimate of the arcs (the default is usually sensible). |
proj4string |
Projection parameters if the alphahull is based on geographic locations. |
An object of class SpatialPolygonsDataFrame
1 2 3 4 5 6 7 8 9 10 11 12 | ##Example point set and its alphahull
n <- 300
theta <- runif(n, 0,2 * pi)
r <- sqrt(runif(n, 0.25^2, 0.5^2))
x <- cbind(0.5 + r*cos(theta), 0.5 + r*sin(theta))
ahullobj <- ahull(x, alpha=0.1)
ahobj <- ah2sp(ahullobj)
## Plot
par(mfrow=c(1,2), pty="s")
plot(ahullobj, main="ahull object")
plot(ahobj, col="lightgrey", pbg="white", axes=TRUE, main="sp object")
points(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.