GetRegionOfInterest: Get Region of Interest

View source: R/GetRegionOfInterest.R

GetRegionOfInterestR Documentation

Get Region of Interest

Description

Create a spatial polygon describing the convex hull of a set of spatial points.

Usage

GetRegionOfInterest(x, y = NULL, alpha = NULL, width = NULL, ...)

Arguments

x, y

Coordinate vectors of a set of points. Alternatively, a single argument x can be provided. Functions xy.coords and coordinates are used to extract point coordinates.

alpha

'numeric' number. Value of α, used to implement a generalization of the convex hull (Edelsbrunner and others, 1983). As α decreases, the shape shrinks. Requires that the alphahull and maptools packages are available. The alphahull package is released under a restrictive non-free software license.

width

'numeric' number. Buffer distance from geometry of convex hull.

...

Additional arguments to be passed to the gBuffer function.

Value

An object of class 'SpatialPolygons'.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

References

Edelsbrunner, H., Kirkpatrick, D.G. and Seidel, R., 1983, On the shape of a set of points in the plane: IEEE Transactions on Information Theory, v. 29, no. 4, p. 551–559.

See Also

Functions chull and ashape are used to calculate the convex hull and generalized convex hull, respectively.

Function checkPolygonsHoles is used to identify polygon holes.

Examples

set.seed(123)

n <- 50
x <- list("x" = stats::runif(n), "y" = stats::runif(n))
sp::plot(GetRegionOfInterest(x, width = 0.05), border = "blue", lty = 2)
sp::plot(GetRegionOfInterest(x), border = "red", add = TRUE)
sp::plot(GetRegionOfInterest(x, width = -0.05), lty = 2, add = TRUE)
points(x, pch = 3)

## Not run: 
n <- 300
theta <- stats::runif(n, 0, 2 * pi)
r <- sqrt(stats::runif(n, 0.25^2, 0.50^2))
x <- sp::SpatialPoints(cbind(0.5 + r * cos(theta), 0.5 + r * sin(theta)),
                       proj4string = sp::CRS("+init=epsg:32610"))
sp::plot(GetRegionOfInterest(x, alpha = 0.1, width = 0.05),
         col = "green")
sp::plot(GetRegionOfInterest(x, alpha = 0.1),
         col = "yellow", add = TRUE)
sp::plot(x, add = TRUE)

## End(Not run)


USGS-R/inlmisc documentation built on Sept. 17, 2022, 2:38 a.m.