points2polygonHull | R Documentation |
Define a polygon hull to encompass a set of data points
points2polygonHull(x, returnClass = c("matrix", "SpatialPolygons"), ...)
x |
two-column numeric matrix of data points, or an object of
class |
returnClass |
character string indicating the class to return,
either |
verbose |
logical whether to print verbose output. |
A polygon hull can be useful as a visual indicator of the location
of a set of points. This function creates a polygon around all points,
and not just the most dense region of points, using
grDevices::chull()
.
The output is slightly modified to duplicate the first coordinate,
in order to "close" the resulting polygon, which is consistent
with the output of rgeos::gConvexHull()
.
A two-column numeric matrix of polygon coordinates when
returnClass="matrix"
by default, or when
returnClass="SpatialPolygons"
it returns an object
of class sp::SpatialPolygons
.
Other jam utility functions:
blockArrowMargin()
,
find_colname()
,
fold_to_log2fold()
,
get_se_assaydata()
,
gradient_rect()
,
handle_highlightPoints()
,
log2fold_to_fold()
,
logAxis()
,
outer_legend()
,
update_function_params()
,
update_list_elements()
set.seed(123);
xy <- cbind(x=1:10,
y=sample(1:10, 10));
xyhull <- points2polygonHull(xy);
plot(xy, pch=20, cex=1, col="purple4",
main="Polygon hull around points");
polygon(xyhull, border="purple2", col="transparent");
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.