The goal ofcomat is to create co-occurrencematrices based on spatial data, including a weighted co-occurrencematrix (wecoma) and an integrated co-occurrence matrix(incoma).
You can install the released version ofcomat fromCRAN with:
install.packages("comat")You can install the development version fromGitHub with:
# install.packages("remotes")remotes::install_github("Nowosad/comat")This is a basic example which shows you how to create a weightedco-occurrence matrix (wecoma) based on two simple rasters (forsimplicity presented as matrices). The first oneraster_xrepresents some categories, and the second oneraster_wrepresents weights.
library(comat)library(raster)#> Loading required package: spdata(raster_x,package ="comat")data(raster_w,package ="comat")raster_x#> [,1] [,2] [,3]#> [1,] 1 1 3#> [2,] 1 3 3#> [3,] 2 2 3raster_w#> [,1] [,2] [,3]#> [1,] 2 2 9#> [2,] 6 4 9#> [3,] 4 8 9Theget_wecoma() function can be next used to create aweighted co-occurrence matrix.
get_wecoma( raster_x, raster_w,neighbourhood =4)#> 1 2 3#> 1 12.0 5.0 13.5#> 2 5.0 12.0 14.5#> 3 13.5 14.5 49.0This function allows for some parametrization using additionalarguments, e.g.:
get_wecoma( raster_x, raster_w,neighbourhood =4,fun ="focal",na_action ="keep")#> 1 2 3#> 1 12 6 10#> 2 4 12 16#> 3 17 13 49For more examples see the package’s vignettes:
Contributions to this package are welcome. The preferred method ofcontribution is through a GitHub pull request. Feel free to contact meby creatinganissue.
To cite thecomat package in publications, please usethis paper:
Nowosad J, Stepinski TF (2021) Pattern-based identification andmapping of landscape types using multi-thematic data, InternationalJournal of Geographical Information Science, DOI:10.1080/13658816.2021.1893324
LaTeX/BibTeX version can be obtained with:
library(comat)citation("comat")