points2polygonHull: define a polygon hull around points

points2polygonHullR Documentation

define a polygon hull around points

Description

Define a polygon hull to encompass a set of data points

Usage

points2polygonHull(x, returnClass = c("matrix", "SpatialPolygons"), ...)

Arguments

x

two-column numeric matrix of data points, or an object of class sp::SpatialPoints.

returnClass

character string indicating the class to return, either "matrix" to return a two-column numeric matrix, or "SpatialPolygons" to return sp::SpatialPolygons.

verbose

logical whether to print verbose output.

Details

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().

Value

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.

See Also

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()

Examples

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");


jmw86069/jamma documentation built on Oct. 11, 2024, 7:08 a.m.