Learn R Programming

geocomplexity (version 0.2.0)

geocs_vector: geocomplexity for spatial vector data based on geographical similarity

Description

This function calculates geocomplexity for in spatial vector data based on geographical similarity.

Usage

geocs_vector(
  sfj,
  wt = NULL,
  method = "spvar",
  similarity = 1,
  normalize = TRUE,
  returnsf = TRUE
)

Value

A tibble (returnsf is FALSE) or an sf object (returnsf is TRUE)

Arguments

sfj

An sf object or spatial vector object that can be converted to sf by sf::st_as_sf().

wt

(optional) Spatial weight matrix. Must be a matrix class. If wt is not provided, geocomplexity will use a first-order inverse distance weight matrix via sdsfun::inverse_distance_swm() function.

method

(optional) When method is spvar, variation of the similarity vector is represented using spatial variance, otherwise shannon information entropy is used. Default is spvar.

similarity

(optional) When similarity is 1, the similarity is calculated using geographical configuration similarity, otherwise the cosine similarity is calculated. Default is 1.

normalize

(optional) Whether to further normalizes the calculated geocomplexity. Default is TRUE.

returnsf

(optional) When returnsf is TRUE, return an sf object, otherwise a tibble. Default is TRUE.

Examples

Run this code
econineq = sf::read_sf(system.file('extdata/econineq.gpkg',package = 'geocomplexity'))
gc = geocs_vector(dplyr::select(econineq,-Gini))
gc

library(ggplot2)
library(viridis)
ggplot(gc) +
   geom_sf(aes(fill = GC)) +
   scale_fill_viridis(option = "mako", direction = -1) +
   theme_bw()

Run the code above in your browser using DataLab