st_inverse_distance: Calculate inverse distance weights

View source: R/weights-inverse-distance.R

st_inverse_distanceR Documentation

Calculate inverse distance weights

Description

From a neighbor list and sf geometry column, calculate inverse distance weight.

Usage

st_inverse_distance(nb, geometry, scale = 100, alpha = 1)

Arguments

nb

a neighbors list object e.g. created by st_knn() or st_contiguity()

geometry

sf geometry

scale

default 100.a value to scale distances by before exponentiating by alpha

alpha

default 1. Set to 2 for gravity weights.

Details

The inverse distance formula is w_{ij} = 1 / d_{ij}^\alpha

Value

a list where each element is a numeric vector

See Also

Other weights: st_kernel_weights(), st_nb_dists(), st_weights()

Examples

geo <- sf::st_geometry(guerry)
nb <- st_contiguity(geo)
wts <- st_inverse_distance(nb, geo)
head(wts, 3)
wts <- st_inverse_distance(nb, geo, scale = 10000)
head(wts, 3)

sfdep documentation built on Sept. 13, 2024, 5:07 p.m.