
geocomplexity for spatial raster data based on geographical similarity
Source:R/geocs_raster.R
geocs_raster.RdThis function calculates geocomplexity for spatial raster data based on geographical similarity.
Arguments
- r
SpatRasterobject or can be converted toSpatRasterbyterra::rast().- order
(optional) The order of the adjacency object. Default is
1.- normalize
(optional) Whether to further normalizes the calculated geocomplexity. Default is
TRUE.- similarity
(optional) When
similarityis1, the similarity is calculated using geographical configuration similarity, otherwise the cosine similarity is calculated. Default is1.- method
(optional) When
methodisspvar, variation of the similarity vector is represented using spatial variance, otherwise shannon information entropy is used. Default isspvar.
Note
In contrast to the geocs_vector() function, the geocs_raster() performs operations
internally on raster data without providing additional wt object.
Examples
library(terra)
m1 = matrix(c(3,3,3,3,1,3,
3,3,3,2,1,2,
3,3,3,1,2,1,
1,3,2,2,2,2,
2,2,2,1,1,2,
1,2,1,1,1,1),
nrow = 6,
byrow = TRUE)
m1 = rast(m1)
names(m1) = 'sim1'
m2 = m1
set.seed(123456789)
values(m2) = values(m1) + runif(ncell(m1),-1,1)
names(m2) = 'sim2'
m = c(m1,m2)
gc1 = geocs_raster(m,1)
gc2 = geocs_raster(m,2)
gc1
#> class : SpatRaster
#> size : 6, 6, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 6, 0, 6 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : GC
#> min value : 0
#> max value : 1
plot(gc1)
gc2
#> class : SpatRaster
#> size : 6, 6, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 6, 0, 6 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : GC
#> min value : 0
#> max value : 1
plot(gc2)