lsp_to_dist: Calculate Distance Matrix

View source: R/lsp_to_dist.R

lsp_to_distR Documentation

Calculate Distance Matrix

Description

Calculates a distance matrix based on an object of class lsp.

Usage

lsp_to_dist(x, dist_fun, unit = "log2", p = NULL)

Arguments

x

An object of class lsp - usually the output of the lsp_signature() function

dist_fun

A distance/dissimilarity method used. All possible values can be found using the philentropy::getDistMethods() function

unit

A character string specifying the logarithm unit that should be used to compute distances that depend on log computations: ⁠"log", "log2", "log10"⁠. The default is "log"

p

Power of the Minkowski distance. Used only when the dist_fun = "minkowski"

Value

An object of class '"dist"“

Examples

library(stars)
landcover = read_stars(system.file("raster/landcover2015s.tif", package = "motif"))

landcover_cove = lsp_signature(landcover, type = "cove", threshold = 0.9, window = 400)
landcover_cove

dist_cov = lsp_to_dist(landcover_cove, dist_fun = "jensen-shannon")
dist_cov


# larger data example
library(stars)
landcover = read_stars(system.file("raster/landcover2015.tif", package = "motif"))

landcover_cove = lsp_signature(landcover, type = "cove", threshold = 0.9, window = 2000)
landcover_cove

dist_cov = lsp_to_dist(landcover_cove, dist_fun = "jensen-shannon")
dist_cov


Nowosad/lopata documentation built on Aug. 27, 2024, 6 a.m.