A collection of functions for sampling and simulating 3D surfaces and objects and estimating metrics like rugosity, fractal dimension, convexity, sphericity, circularity, second moments of area and volume, and more.
Installation
The best way to install habtools
is through cran.
install.packages("habtools")
You can also install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("jmadinlab/habtools")
Examples
There are vignettes demonstrating the use of habtools
for digital elevation models (DEMs) and 3D meshes, as well as a vignette covering fractal dimension methods.
There are currently two data sets accompanying this package. horseshoe
is a DEM of a coral reef in RasterLayer format, and mcap
is a 3D mesh of a coral growing on a reef in mesh3d format.
The following example calculates height range, rugosity and fractal dimension of a 2 x 2 m plot of horseshoe
.
library(habtools)
library(raster)
# Let's take a subset DEM of size = 2
dem <- dem_crop(horseshoe, x0 = -465, y0 = 1265, L = 2, plot = TRUE)
# height range
hr(dem)
#> [1] 1.368289
# rugosity
rg(dem, L0 = 0.0625)
#> [1] 1.75829
# fractal dimension
fd(dem, method = "hvar", keep_data = TRUE, plot=TRUE, diagnose = TRUE)
#> $D
#> [1] 2.159332
#>
#> $data
#> l h
#> 1 0.0625 0.07207143
#> 2 0.1250 0.16465515
#> 3 0.2500 0.31394699
#> 4 0.5000 0.58224221
#> 5 1.0000 0.88901201
#> 6 2.0000 1.36828852
#>
#> $lvec
#> [1] 0.0625 0.1250 0.2500 0.5000 1.0000 2.0000
#>
#> $D_vec
#> [1] 1.808052 2.068927 2.108902 2.389417 2.377902
#>
#> $var
#> [1] 0.2420993
#>
#> $method
#> [1] "hvar"
The next example calculates height range, rugosity and fractal dimension for the coral colony mcap
. Because 3D meshes can have more than one z
coordinate for a given xy
(i.e., they have overhangs), we use cube counting for fractal dimension.