Learn R Programming

lctools (version 0.2-10)

lat2w: Contiguity-based weights matrix for a regular grid

Description

This function creates a contiguity-based (Rook or Queen) weights matrix for a regular grid with equal number of rows and columns

Usage

lat2w(nrows=5, ncols=5, rook=TRUE)

Value

Returns a list of neighbours for each cell of the grid as well as a weights matrix.

nbs

a list of neighbours for each observation

w

a matrix of weights

Arguments

nrows

number of rows

ncols

number of columns (identical to the number of rows)

rook

a TRUE/FALSE option. TRUE refers to a rook contiguity and FALSE to queen contiguity

Author

Stamatis Kalogirou <stamatis.science@gmail.com

Details

This function may also serve in simulations.

References

Kalogirou, S. (2003) The Statistical Analysis and Modelling of Internal Migration Flows within England and Wales, PhD Thesis, School of Geography, Politics and Sociology, University of Newcastle upon Tyne, UK. https://theses.ncl.ac.uk/jspui/handle/10443/204

Kalogirou, S. (2015) Spatial Analysis: Methodology and Applications with R. [ebook] Athens: Hellenic Academic Libraries Link. ISBN: 978-960-603-285-1 (in Greek). https://repository.kallipos.gr/handle/11419/5029?locale=en

See Also

w.matrix, moransI.w, spGini.w

Examples

Run this code
#rook weights matrix for a 5 by 5 grid
w.mat <- lat2w(nrows=5, ncols=5)

Run the code above in your browser using DataLab