View source: R/reg_distinction.R
reg_distinction | R Documentation |
Distinction is an average distance between the focus region and all of the other regions. This value is between 0 and 1, where large value indicates that the values in the region stands out from the other regions.
reg_distinction(
region,
raster,
dist_fun = "euclidean",
sample_size = 1,
unit = "log2",
na.rm = FALSE,
...
)
region |
An object of class |
raster |
An object of class SpatRaster (terra) |
dist_fun |
Distance measure used. This function uses |
sample_size |
Proportion of the cells inside of each region to be used in calculations. Value between 0 and 1. It is also possible to specify an integer larger than 1, in which case the specified number of cells of each region will be used in calculations. |
unit |
a character string specifying the logarithm unit that should be used to compute distances that depend on log computations. |
na.rm |
Whether NA values should be stripped from the calculations. |
... |
Additional arguments for |
A vector with the distinction values
## Not run:
library(terra)
if (requireNamespace("sf", quietly = TRUE)) {
library(sf)
volcano = rast(system.file("raster/volcano.tif", package = "regional"))
vr = read_sf(system.file("regions/volcano_regions.gpkg", package = "regional"))
vr$dis = reg_distinction(vr, volcano, sample_size = 0.5)
mean(vr$dis)
plot(volcano)
plot(vect(vr), add = TRUE)
plot(volcano)
plot(vr["dis"], add = TRUE)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.