Rugosity is defined as the surface area divided by the planar area. For digital elevation models, there are two methods: "hvar" and "area".
The "hvar" method for calculating rugosity is described in Torres-Pulliza et al. (2004) and is based on height variations.
The "area" method uses the `sp::surfaceArea()`

function and is detailed in Jenness (2004).
`method`

is ignored if `data`

is a mesh3D object.
In that case the function uses `Rvcg::vcgArea()`

to calculate surface area of a triangular mesh of class mesh3d.

```
rg(
data,
L0,
method = "area",
parallel = FALSE,
ncores = (parallel::detectCores() - 1)
)
```

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

- L0
Grain or resolution of calculation.

- method
If data is a RasterLayer methods "hvar" or "area" are allowed. Defaults to "hvar".

- parallel
Logical. Use parallel processing? Defaults to FALSE.

- ncores
Number of cores to use if parallel = TRUE. (Defaults to umber of available cores - 1)

Rugosity value

Jenness, J.S. Calculating Landscape Surface Area from Digital Elevation Models. Wildlife Society Bulletin, Vol. 32, No. 3 (Autumn, 2004), pp. 829-839n

Torres-Pulliza, D., Dornelas, M.A., Pizarro, O. et al. A geometric basis for surface habitat complexity and biodiversity. Nat Ecol Evol 4, 1495–1501 (2020). https://doi.org/10.1038/s41559-020-1281-8

```
rg(horseshoe, L0 = 0.1)
#> [1] 1.406815
rg(mcap, L0 = 0.01)
#> [1] 3.243748
```