It creates a patternogram or a patternogram cloud. The function takes a raster object of class SpatRaster or a point vector object of class sf as input, and calculates the dissimilarity between values of pairs of points given the distances between them. The output of this function is a tibble of the patternogram class that can be visualized with the plot() and autoplot() functions.

patternogram(
  x,
  cutoff,
  width = cutoff/15,
  dist_fun = "euclidean",
  sample_size = 500,
  cloud = FALSE,
  target = NULL,
  ...
)

Arguments

x

A raster object of class SpatRaster (terra) or a point vector object of class sf (sf)

cutoff

Spatial distance up to which point pairs are included in patternogram estimates; by default: a square root of the raster area

width

The width of subsequent distance intervals for which data point pairs are grouped for patternogram estimates

dist_fun

Distance measure used. This function uses the philentropy::distance() function (run philentropy::getDistMethods() to find possible distance measures)

sample_size

Only used when x is raster. 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.

cloud

Logical; if TRUE, calculate the patternogram cloud

target

Additional argument allowing to calculate separate estimates for different categories or ranges of values

...

Additional arguments for base::cut()

Value

A tibble of the patternogram class with columns, such as (a) np - the number of point pairs in this estimate, (b) dist - the middle of the distance interval used for each estimate, (c) dissimilarity - the dissimilarity estimate, (d) (optional) target

Examples

r = terra::rast(system.file("ex/elev.tif", package = "terra"))
pr = patternogram(r)
pr
#> # A tibble: 15 × 3
#>       np  dist dissimilarity
#>  * <int> <dbl>         <dbl>
#>  1  2864  2300          41.5
#>  2  7679  6895          54.2
#>  3 11256 11495          61.3
#>  4 13171 16100          66.9
#>  5 14335 20700          71.2
#>  6 14224 25300          74.5
#>  7 12958 29900          82.2
#>  8 11690 34500          93.4
#>  9  9905 39100         109. 
#> 10  8362 43700         124. 
#> 11  6415 48300         139. 
#> 12  4734 52900         154. 
#> 13  3010 57450         168. 
#> 14  2014 62000         179. 
#> 15  1209 66600         190. 
plot(pr)