Learn R Programming

lidR (version 4.1.2)

st_hull: Concave and convex hulls for LAS objects

Description

Concave and convex hulls for LAS objects. st_convex_hull extends sf::st_convex_hull for LAS objects. Both functions return a sfc_POLYGON. concaveman is very a fast 2D concave hull algorithm for a set of points.

Usage

st_concave_hull(x, method = "concaveman", ...)

# S3 method for LAS st_convex_hull(x)

concaveman(x, y = NULL, concavity = 2, length_threshold = 0)

Value

A sfc_POLYGON from sf or a data.frame in the case of concaveman

Arguments

x, y

An object of class LAS or XY coordinates of points in case of concaveman. This can be specified as two vectors x and y, a 2-column matrix x, a list with two components, etc.

method

string. currently supports "concaveman".

...

Propagate to the method.

concavity

numeric a relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes.

length_threshold

numeric. When a segment length is below this threshold, it stops being considered for further detailed processing. Higher values result in simpler shapes.

Details

The concaveman algorithm is based on ideas from Park and Oh (2012). A first implementation in JavaScript was proposed by Vladimir Agafonkin in mapbox. This implementation dramatically improved performance over the one stated in the paper using a spatial index. The algorithm was then ported to R by Joël Gombin in the R package concaveman that runs the JavaScript implementation proposed by Vladimir Agafonkin. Later, a C++ version of Vladimir Agafonkin's JavaScript implementation was proposed by Stanislaw Adaszewski in concaveman-cpp. This concaveman function uses Stanislaw Adaszewski's C++ code making the concaveman algorithm an order of magnitude (up to 50 times) faster than the Javascript version.

References

Park, J.-S & Oh, S.-J. (2013). A New Concave Hull Algorithm and Concaveness Measure for n-dimensional Datasets. Journal of Information Science and Engineering. 29. 379-392.

Examples

Run this code
x <- runif(35)
y <- runif(35)
hull <- concaveman(x,y)
plot(x,y, asp = 1)
lines(hull, lwd = 3, col = "red")

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las = readLAS(LASfile, filter = "-drop_z_below 1")
hull = st_concave_hull(las, length_threshold = 10)
plot(hull)

Run the code above in your browser using DataLab