| hull | R Documentation |
Compute hulls around SpatVector geometries. This can be the convex hull, the minimal bounding rotated rectangle, the minimal bounding circle, or a concave hull. The concaveness of the concave hull can be specified in different ways.
The old method convHull is deprecated and will be removed in a future version.
## S4 method for signature 'SpatVector'
hull(x, type="convex", by="", param=1, allowHoles=TRUE, tight=TRUE, percent=100)
x |
SpatVector |
type |
character. One of "convex", "rectangle", "circle", "concave_ratio", "concave_length" |
by |
character (variable name), to get a new geometry for groups of input geometries. Use |
param |
numeric. For |
allowHoles |
logical. May the output polygons contain holes? For "concave_*" methods only |
tight |
logical. Should the hull follow the outer boundaries of the input polygons? For "concave_length" with polygon geometry only |
percent |
numeric > 0 and <= 100. If below 100, only that percentage of geometries closest to the centroid is used |
A concave hull is a polygon which contains all the points of the input. It can be a better representation of the input data (typically points) than the convex hull. There are many possible concave hulls with different degrees of concaveness. These can be created with argument param.
For type="concave_ratio", larger ratios retain longer edges. A ratio of 0 gives the most concave hull and 1 gives the convex hull. This method requires GEOS 3.11 or later.
For type="concave_length" with polygons, the ratio applies to the edges between polygons. At 0 the original polygons are retained. The tight argument controls whether the hull follows their outer boundaries. This method requires GEOS 3.11 or later. For points and lines, a larger maximum edge length gives a less concave hull. This method requires GEOS 3.12 or later.
SpatVector
p <- vect(system.file("ex/lux.shp", package="terra"))
h <- hull(p)
plot(p)
lines(h, col="orange")
hh <- hull(p, "convex", by="NAME_1")
lines(hh, col="purple")
pts <- centroids(p)
plot(pts, ext=ext(p)+0.1)
lines(hull(pts, type="convex"), col="darkgreen")
lines(hull(pts, type="rectangle"), col="blue")
lines(hull(pts, type="circle"), col="red")
lines(hull(pts, percent=60), col="orange")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.