ah2sp: Convert an alphahull to a SpatialPolygonsDataFrame

Description Usage Arguments Value Examples

View source: R/convertformats.R

Description

Convert an ahull object from the alphahull package to a SpatialPolygonsDataFramefor wider use.

Usage

1
ah2sp(x, increment = 360, rnd = 10, proj4string = CRS(as.character(NA)))

Arguments

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.

Value

An object of class SpatialPolygonsDataFrame

Examples

 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)

ahb108/sparch documentation built on Feb. 3, 2021, 1:21 a.m.