lsp_compare {motif} | R Documentation |
Comparison between spatial patterns
Description
Compares two spatial datasets containing categorical raster data.
It accepts a categorical raster dataset with one or more attributes, and compares it to the second dataset with the same attributes and dimensions.
The both dataset are either compared to as whole areas, areas divided into regular windows, or areas divided into irregular windows.
This function allows for several types of comparisons using different representations of spatial patterns, including "coma" (co-occurrence matrix), "cove" (co-occurrence vector), "cocoma" (co-located co-occurrence matrix), "cocove" (co-located co-occurrence vector), "wecoma" (weighted co-occurrence matrix), "wecove" (weighted co-occurrence vector), "incoma" (integrated co-occurrence matrix), "incove" (integrated co-occurrence vector). These representations are created for both datasets, and next a distance between them is calculated using a selected measure from the philentropy::distance
function.
Additional parameters, such as neighbourhood or normalization types, are also available.
Usage
lsp_compare(
x,
y,
type,
dist_fun,
window = NULL,
output = "stars",
neighbourhood = 4,
threshold = 0.5,
ordered = FALSE,
repeated = FALSE,
normalization = "pdf",
wecoma_fun = "mean",
wecoma_na_action = "replace",
...
)
Arguments
x |
Object of class |
y |
Object of class |
type |
Type of the calculated signature. It can be |
dist_fun |
Distance measure used. This function uses the |
window |
Specifies areas for analysis. It can be either: |
output |
The class of the output. Either |
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. |
threshold |
The share of NA cells to allow metrics calculation. |
ordered |
For |
repeated |
For |
normalization |
For |
wecoma_fun |
For |
wecoma_na_action |
For |
... |
Additional arguments for the |
Value
Object of class stars
(or sf
or terra's SpatRaster
, depending on the output
argument).
It has four attributes:
(1) id
- an id of each window.
For irregular windows, it is the values provided in the window
argument,
(2) na_prop_x
- share (0-1) of NA
cells for each window in the x
object,
(3) na_prop_y
- share (0-1) of NA
cells for each window in the y
object,
(4) dist
- calculated distance between signatures for each window
Examples
library(stars)
lc15 = read_stars(system.file("raster/landcover2015s.tif", package = "motif"))
lc01 = read_stars(system.file("raster/landcover2001s.tif", package = "motif"))
ecoregions = read_sf(system.file("vector/ecoregionss.gpkg", package = "motif"))
ecoregions = st_transform(ecoregions, st_crs(lc15))
c1 = lsp_compare(lc01, lc15, type = "cove",
dist_fun = "jensen-shannon", window = ecoregions["id"])
plot(c1["dist"])
# larger data example
library(stars)
lc15 = read_stars(system.file("raster/landcover2015.tif", package = "motif"))
lc01 = read_stars(system.file("raster/landcover2001.tif", package = "motif"))
ecoregions = read_sf(system.file("vector/ecoregions.gpkg", package = "motif"))
ecoregions = st_transform(ecoregions, st_crs(lc15))
c1 = lsp_compare(lc01, lc15, type = "cove",
dist_fun = "jensen-shannon", window = ecoregions["id"])
plot(c1["dist"])