knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The sabre (Spatial Association Between REgionalizations) is an R package for calculating a degree of spatial association between regionalizations or categorical maps.
This package offers support for sf
, RasterLayer
, SpatRaster
, and stars
spatial objects, and the following methods:
You can install the released version of sabre
from CRAN with:
install.packages("sabre")
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("Nowosad/sabre")
We use two simple regionalization, regions1
and regions2
to show the basic concept of calculating a degree of spatial association.
library(sabre) library(sf) data("regions1") data("regions2")
The first map, regions1
consists of four regions of the same shape and size, while the second one, regions2
has three irregular regions.
plot(regions1, main = "regions1") plot(regions2, main = "regions2")
The vmeasure_calc()
function allows for calculation of a degree of spatial association between regionalizations or categorical maps using the information-theoretical V-measure.
It requires, at least, four arguments:
x
- an sf
object containing the first regionalizationx_name
- a name of the column with regions names of the first regionalizationy
- an sf
object containing the second regionalizationy_name
- a name of the column with regions names of the second regionalizationregions_vm = vmeasure_calc(x = regions1, y = regions2, x_name = z, y_name = z)
The result is a list with three metrics of spatial association - V-measure
, Homogeneity
, Completeness
- and two sf
objects with preprocessed input maps - $map1
and $map2
.
regions_vm
Both spatial outputs have two columns.
The first one contains regions' names/values and the second one (rih
) describes regions' inhomogeneities.
plot(regions_vm$map1["rih"], main = "Map1: rih") plot(regions_vm$map2["rih"], main = "Map2: rih")
plot(regions_vm$map1["rih"], main = "Map1: rih"); plot(regions_vm$map2["rih"], main = "Map2: rih")
More examples can be found in the package vignette and in the sabre: or how to compare two maps? blog post.
Hex logo was created with hexmake using icons made by Smashicons and Creaticca Creative Agency from www.flaticon.com.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.