Skip to contents

Calculate fractal dimension

Usage

fd(data, method, lvec, keep_data = FALSE, diagnose = FALSE, ...)

Arguments

data

Digital elevation model of class RasterLayer or a triangular mesh of class mesh3d.

method

If data is a RasterLayer, possible methods are:"hvar", "area", "sd", and "cubes" (defaults to "hvar"). If data is a mesh3d, possible methods are "cubes" and "area" (defaults to "cubes").

lvec

Vector of scales to use for calculation.

keep_data

Logical. Keep data? Default is FALSE.

diagnose

Logical. Show diagnostic plot and metrics?

...

Arguments from method-specific fd_ functions.

Value

A value for fractal dimension, typically between 2 and 3 or a list if keep_data = TRUE.

Details

Calculates fractal dimension using the specified method. Note that methods are distinctly different and should not be mixed when comparing values for multiple objects. See fd_hvar(), fd_area(), fd_cubes(), fd_sd() for details about each method. If lvec is not specified, a default based on resolution, extent, and method will be used. The cubes method is not recommended if the height range is much smaller than the extent of a 3d object or DEM, which is typically the case for DEMs. Most objects and surfaces are not perfectly fractal. It is recommended to investigate scale transitions by setting diagnose to TRUE.

Examples

# \donttest{
dem <- dem_crop(horseshoe, x0 = -469, y0 = 1267, L = 2, plot = TRUE)

fd(dem, method = "hvar", lvec = c(0.125, 0.25, 0.5, 1, 2))
#> [1] 2.215566
fd(dem, method = "area", diagnose = TRUE)
#> lvec is set to c(0.031, 0.062, 0.125, 0.25).

#> $D
#> [1] 2.12649
#> 
#> $data
#>         l     area
#> 1 0.03125 6.955913
#> 2 0.06250 6.360668
#> 3 0.12500 5.672804
#> 4 0.25000 5.395079
#> 
#> $lvec
#> [1] 0.03125 0.06250 0.12500 0.25000
#> 
#> $D_vec
#> [1] 2.129062 2.165116 2.072418
#> 
#> $var
#> [1] 0.04672865
#> 
#> $method
#> [1] "area"
#> 
fd(dem, method = "sd")
#> lvec is set to c(0.062, 0.125, 0.25, 0.5, 1, 2).
#> [1] 2.145932
fd(mcap2, method = "cubes",  plot = TRUE)
#> lvec is set to c(0.013, 0.025, 0.051, 0.102, 0.203, 0.406).

#> [1] 2.199604
fd(mcap2, method = "area",  diagnose = TRUE)
#> lvec is set to c(0.005, 0.007, 0.01, 0.014, 0.02).

#> $D
#> [1] 2.032347
#> 
#> $data
#>             l      area
#> 1 0.005117204 0.2832553
#> 2 0.007185740 0.2827583
#> 3 0.010090444 0.2812195
#> 4 0.014169322 0.2773298
#> 5 0.019897011 0.2707333
#> 
#> $lvec
#> [1] 0.005117204 0.007185740 0.010090444 0.014169322 0.019897011
#> 
#> $D_vec
#> [1] 2.005173 2.016074 2.041027 2.070910
#> 
#> $var
#> [1] 0.02922383
#> 
#> $method
#> [1] "area"
#> 
# }