Skip to contents

Compares values between two rasters based on a given distance measure.

Usage

spq_compare(x, y, dist_fun, ...)

Arguments

x

An object of class SpatRaster (terra)

y

An object of class SpatRaster (terra)

dist_fun

Distance measure used. This function uses the philentropy::distance function (run philentropy::getDistMethods() to find possible distance measures), proxy::dist in the background. It is also possible to use "dtw" (dynamic time warping)

...

Additional arguments for philentropy::dist_one_one, proxy::dist, or dtwclust::dtw_basic. When dist_fun = "dtw" is used, ndim should be set to specify how many dimension the input raster time-series has.

Value

An object of class SpatRaster (terra)

Examples

library(terra)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
ta = rast(system.file("raster/ta_scaled.tif", package = "spquery"))
pr = rast(system.file("raster/pr_scaled.tif", package = "spquery"))

re = spq_compare(ta, pr, dist_fun = "jensen-shannon")
plot(re)