The spatLac
R package helps researchers compute Lacunarity for binary
and continuous Spatial Raster objects. spatLac
uses fast C++ code,
allowing for low memory usage and multithreading.
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("STBrinkmann/spatLac")
“Lacunarity” literally refers to the gappiness or heterogeneity of a fractal or non-fractal image. As a scale dependent measure of heterogeneity, Dong (2000) introduced lacunarity for spatial heterogeneity measurements in GIS. Based on the research of Plotnick et al. (1993) he implemented a Lacunarity algorithm for raster images. Hoechstetter et al. (2011) further improved Lacunarity measurements for continuous images. In a recent paper Labib et al. (2020) applied Lacunarity on binary (Land Use) and continuous (NDVI and LAI) raster images, to derive scale sensitive weights used in a buffer analysis to build multiple-exposure metrics.
To compute Lacunarity we use a sliding box algorithm, the box can be either square or round as demonstrated in the animation below.
Lacunarity for binary raster images is calculated using Eq. 1-5, for continuous images only function 1 and 6 are being used.
Lacunarity (“lambda”) for box diameter of an image with width and length is beeing calculated as follows:
First the total number of boxes can be described as (Eq. 1):
Next, the box mass for each box of size is beeing calculated by taking the box sum, or the range of all box-values, for binary or continuous raster, respectively.
For binary images, the number of boxes of size containing box mass are counted as , and converted into a probability distribution by dividing by (Eq. 2):
Next, the first and second moments of this probability distribution are estimated using Eq. (3), (4) respectively:
Lacunarity can now be computed as (Eq. 5):
If the raster is continuous the first and second moment can be expressed as the mean and variance of the box mass values, respectively. Lacunarity can now be derived as (Eg. 6):
should not be greater than half of the shorter dimension of the input raster. If is not provided by the user, it will be automatically generated as the function , where is a whole number commencing at 1 until reaches half of the shorter dimension.
For demonstration purposes I replicated the examples provided by Hoechstetter et al. (2011).
library(spatLac)
library(terra)
sample_rast <- rast("data_raw/hoechstetter.tif")
sample_lac <- lacunarity(x = sample_rast, r_vec = 3:50, plot = TRUE)
To compute Lacunarity for a larger study, it can be computed for all raster objects (ending with .tif) in a folder. Furthermore, individual and summary plots can be automatically created, too.
lacunarity(x = "folder_path_with_TIF_files",
save_plot = "folder_path_to_save_plots")
Run this command to get info on how to cite this package.
citation("spatLac")
#>
#> To cite spatLac in publications use:
#>
#> Brinkmann, S.T. (2021). spatLac: R package for computing Lacunarity
#> for Spatial Raster. doi: 10.5281/zenodo.5786547.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {spatLac: R package for computing Lacunarity for Spatial Raster},
#> author = {Brinkmann S.T.},
#> year = {2021},
#> url = {https://doi.org/10.5281/zenodo.5786547},
#> }
Brinkmann, Sebastian (Creator and author) e-mail: sebastian.brinkmann@fau.de
Dr. S.M. Labib (Contributor) e-mail: sml80@medschl.cam.ac.uk
Dong P. (2000): Lacunarity for Spatial Heterogeneity Measurement in GIS. Geographic Information Sciences 6:1, pages 20-26. DOI: 10.1080/10824000009480530.
Hoechstetter S., Walz U. and Thinh N.X. (2011): Adapting lacunarity techniques for gradient-based analyses of landscape surfaces. Ecological Complexity 8:3, pages 229-238. DOI: 10.1016/j.ecocom.2011.01.001.
Labib S.M., Lindley S. and Huck J.J. (2020): Scale effects in remotely sensed greenspace metrics and how to mitigate them for environmental health exposure assessment. Computers, Environment and Urban Systems 82. DOI: 10.1016/j.compenvurbsys.2020.101501.
Plotnick R.E., Gardner R.H. and O’Neill R.V. (1993): Lacunarity indices as measures of landscape texture. Landscape Ecology 8, pages 201–211. DOI: 10.1007/BF00125351