Title: | Creates Co-Occurrence Matrices of Spatial Data |
---|---|
Description: | Builds co-occurrence matrices based on spatial raster data. It includes creation of weighted co-occurrence matrices (wecoma) and integrated co-occurrence matrices (incoma; Vadivel et al. (2007) <doi:10.1016/j.patrec.2007.01.004>). |
Authors: | Jakub Nowosad [aut, cre] |
Maintainer: | Jakub Nowosad <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.9.5 |
Built: | 2025-02-04 05:25:53 UTC |
Source: | https://github.com/nowosad/comat |
Create a co-located co-occurrence matrix (cocoma)
get_cocoma(x, y, neighbourhood = 4, classes = NULL)
get_cocoma(x, y, neighbourhood = 4, classes = NULL)
x |
A matrix with categories |
y |
A matrix with categories |
neighbourhood |
The number of directions in which cell adjacencies are considered as neighbours: 4 (rook's case) or 8 (queen's case). The default is 4. |
classes |
A list of length 2 with the values of selected classes from the |
A co-located co-occurrence matrix
library(comat) data(raster_x, package = "comat") data(raster_x_na, package = "comat") coom = get_cocoma(raster_x, raster_x_na) coom get_cocoma(raster_x, raster_x_na, classes = list(c(1, 2), 3))
library(comat) data(raster_x, package = "comat") data(raster_x_na, package = "comat") coom = get_cocoma(raster_x, raster_x_na) coom get_cocoma(raster_x, raster_x_na, classes = list(c(1, 2), 3))
Converts a co-located co-occurrence matrix (cocoma) to a co-located co-occurrence vector (cocove)
get_cocove(x, ordered = TRUE, normalization = "none")
get_cocove(x, ordered = TRUE, normalization = "none")
x |
A matrix - an output of the |
ordered |
The type of pairs considered. Either "ordered" (TRUE) or "unordered" (FALSE). The default is TRUE. |
normalization |
Should the output vector be normalized? Either "none" or "pdf". The "pdf" option normalizes a vector to sum to one. The default is "none". |
A co-located co-occurrence vector
library(comat) data(raster_x, package = "comat") data(raster_x_na, package = "comat") coom = get_cocoma(raster_x, raster_x_na) coom coov = get_cocove(coom) coov
library(comat) data(raster_x, package = "comat") data(raster_x_na, package = "comat") coom = get_cocoma(raster_x, raster_x_na) coom coov = get_cocove(coom) coov
Create a co-occurrence matrix (coma)
get_coma(x, neighbourhood = 4, classes = NULL)
get_coma(x, neighbourhood = 4, classes = NULL)
x |
A matrix with categories |
neighbourhood |
The number of directions in which cell adjacencies are considered as neighbours: 4 (rook's case) or 8 (queen's case). The default is 4. |
classes |
A vector or a list with the values of selected classes from the |
A co-occurrence matrix
#library(comat) data(raster_x, package = "comat") com = get_coma(raster_x) com com2 = get_coma(raster_x, classes = c(1, 3)) com2 data(raster_x_na, package = "comat") com3 = get_coma(raster_x_na, classes = c(0:3, NA)) com3
#library(comat) data(raster_x, package = "comat") com = get_coma(raster_x) com com2 = get_coma(raster_x, classes = c(1, 3)) com2 data(raster_x_na, package = "comat") com3 = get_coma(raster_x_na, classes = c(0:3, NA)) com3
Converts a co-occurrence matrix (coma) to a co-occurrence vector (cove)
get_cove(x, ordered = TRUE, normalization = "none")
get_cove(x, ordered = TRUE, normalization = "none")
x |
A matrix - an output of the |
ordered |
The type of pairs considered. Either "ordered" (TRUE) or "unordered" (FALSE). The default is TRUE. |
normalization |
Should the output vector be normalized? Either "none" or "pdf". The "pdf" option normalizes a vector to sum to one. The default is "none". |
A co-occurrence vector
library(comat) data(raster_x, package = "comat") com = get_coma(raster_x) com cov = get_cove(com) cov cov = get_cove(com, normalization = "pdf") cov
library(comat) data(raster_x, package = "comat") com = get_coma(raster_x) com cov = get_cove(com) cov cov = get_cove(com, normalization = "pdf") cov
Create an integrated co-occurrence matrix (incoma)
get_incoma(x, neighbourhood = 4, classes = NULL)
get_incoma(x, neighbourhood = 4, classes = NULL)
x |
A list object containing categorical matrices with categories |
neighbourhood |
The number of directions in which cell adjacencies are considered as neighbours: 4 (rook's case) or 8 (queen's case). The default is 4. |
classes |
A list of the same length as |
An integrated co-occurrence matrix
data(raster_x, package = "comat") data(raster_w, package = "comat") x = list(raster_x, raster_w, raster_x) get_incoma(x) get_incoma(x, classes = list(1:2, 2:4, 1))
data(raster_x, package = "comat") data(raster_w, package = "comat") x = list(raster_x, raster_w, raster_x) get_incoma(x) get_incoma(x, classes = list(1:2, 2:4, 1))
Converts an integrated co-occurrence matrix (incoma) to an integrated co-occurrence vector (incove)
get_incove(x, ordered = TRUE, repeated = TRUE, normalization = "none")
get_incove(x, ordered = TRUE, repeated = TRUE, normalization = "none")
x |
A matrix - an output of the |
ordered |
The type of pairs considered. Either "ordered" (TRUE) or "unordered" (FALSE). The default is TRUE. See details for more explanation. |
repeated |
Should the repeated co-located co-occurrence matrices be used? Either "repeated" (TRUE) or "unrepeated" (FALSE). The default is TRUE. See details for more explanation. |
normalization |
Should the output vector be normalized? Either "none" or "pdf". The "pdf" option normalizes a vector to sum to one. The default is "none". |
All values are kept when ordered = TRUE
and repeated = TRUE
.
When ordered = TRUE
and repeated = FALSE
all values from cocoma (but only one cocoma for each pair) and all coma values are kept.
ordered = FALSE
and repeated = TRUE
keeps all values from cocoma, but divides coma values by 2.
ordered = FALSE
and repeated = FALSE
keeps all values from cocoma (but only one cocoma for each pair), and divides coma values by 2.
An integrated co-occurrence vector
library(comat) data(raster_x, package = "comat") data(raster_w, package = "comat") x = list(raster_x, raster_w, raster_x) incom = get_incoma(x) incom incov1 = get_incove(incom) incov1 incov2 = get_incove(incom, ordered = FALSE) incov2 incov3 = get_incove(incom, ordered = FALSE, normalization = "pdf") incov3
library(comat) data(raster_x, package = "comat") data(raster_w, package = "comat") x = list(raster_x, raster_w, raster_x) incom = get_incoma(x) incom incov1 = get_incove(incom) incov1 incov2 = get_incove(incom, ordered = FALSE) incov2 incov3 = get_incove(incom, ordered = FALSE, normalization = "pdf") incov3
Create a weighted co-occurrence matrix (wecoma)
get_wecoma( x, w, neighbourhood = 4, classes = NULL, fun = "mean", na_action = "replace" )
get_wecoma( x, w, neighbourhood = 4, classes = NULL, fun = "mean", na_action = "replace" )
x |
A matrix with categories |
w |
A matrix with weights |
neighbourhood |
The number of directions in which cell adjacencies are considered as neighbours: 4 (rook's case) or 8 (queen's case). The default is 4. |
classes |
A vector or a list with the values of selected classes from the |
fun |
Function to calculate values from adjacent cells to contribute to output matrix, |
na_action |
Decides on how to behave in the presence of missing values in |
A weighted co-occurrence matrix
library(comat) data(raster_x, package = "comat") data(raster_w, package = "comat") wom = get_wecoma(raster_x, raster_w) wom get_wecoma(raster_x, raster_w, classes = list(c(1, 3)))
library(comat) data(raster_x, package = "comat") data(raster_w, package = "comat") wom = get_wecoma(raster_x, raster_w) wom get_wecoma(raster_x, raster_w, classes = list(c(1, 3)))
Converts a weighted co-occurrence matrix (wecoma) to a weighted co-occurrence vector (wecove)
get_wecove(x, ordered = TRUE, normalization = "none")
get_wecove(x, ordered = TRUE, normalization = "none")
x |
A matrix - an output of the |
ordered |
The type of pairs considered. Either "ordered" (TRUE) or "unordered" (FALSE). The default is TRUE. |
normalization |
Should the output vector be normalized? Either "none" or "pdf". The "pdf" option normalizes a vector to sum to one. The default is "none". |
A weighted co-occurrence vector
library(comat) data(raster_x, package = "comat") data(raster_w, package = "comat") wom = get_wecoma(raster_x, raster_w) wom wov = get_wecove(wom) wov
library(comat) data(raster_x, package = "comat") data(raster_w, package = "comat") wom = get_wecoma(raster_x, raster_w) wom wov = get_wecove(wom) wov
Calculates a selected Information Theory-based metric based on a provided co-occurrence matrix
it_metric(x, metric, base = "log2", ordered = TRUE)
it_metric(x, metric, base = "log2", ordered = TRUE)
x |
A matrix - an output of the |
metric |
One of the following: "ent" (Marginal entropy), "joinent" (Joint entropy), "condent" (Conditional entropy), "mutinf" (Mutual information), or "relmutinf" (Relative mutual information) |
base |
The unit in which entropy is measured. The default is "log2", which compute entropy in "bits". "log" and "log10" can be also used. |
ordered |
The type of pairs considered. Either "ordered" (TRUE) or "unordered" (FALSE). The default is TRUE. |
A single numeric value
Nowosad J., TF Stepinski. 2019. Information theory as a consistent framework for quantification and classification of landscape patterns. https://doi.org/10.1007/s10980-019-00830-x
library(comat) data(raster_x, package = "comat") com = get_coma(raster_x) com it_metric(com, metric = "ent") it_metric(com, metric = "joinent") it_metric(com, metric = "condent") it_metric(com, metric = "mutinf") it_metric(com, metric = "relmutinf")
library(comat) data(raster_x, package = "comat") com = get_coma(raster_x) com it_metric(com, metric = "ent") it_metric(com, metric = "joinent") it_metric(com, metric = "condent") it_metric(com, metric = "mutinf") it_metric(com, metric = "relmutinf")
A matrix with weights
data(raster_w)
data(raster_w)
A matrix
A matrix with weights and missing values
data(raster_w_na)
data(raster_w_na)
A matrix
A matrix with categories
data(raster_x)
data(raster_x)
A matrix
A matrix with categories and missing values
data(raster_x_na)
data(raster_x_na)
A matrix
A matrix with categories
data(raster_y)
data(raster_y)
A matrix