Learn R Programming

spqdep (version 0.1.3.3)

nb2nb_order: A function to order the elements of the m_i-subrrounds

Description

An auxiliary function. In the case of obtaining the list of neighbors of class nb or poly2nb, it is necessary to reorder the elements based on distance and/or angle.

Usage

nb2nb_order(listw = listw, sf = NULL)

Value

An object of the nb class with the elements in order.

Arguments

listw

an object of the nb class.

sf

the sf object used to get the listw .

Author

Fernando Lópezfernando.lopez@upct.es
Román Mínguezroman.minguez@uclm.es
Antonio Páezpaez@gmail.com
Manuel Ruizmanuel.ruiz@upct.es

@references

  • Ruiz, M., López, F., and Páez, A. (2021). A test for global and local homogeneity of categorical data based on spatial runs. Working paper.

Details

Sort the elements of a list nb. First by distance and

See Also

dgp.spq, sp.runs.test, local.sp.runs.test

Examples

Run this code

# With a sf object (irregular lattice)
library(sf)
fname <- system.file("shape/nc.shp", package="sf")
nc <- sf::st_read(fname)
listw <- spdep::poly2nb(as(nc,"Spatial"), queen = FALSE)
listw.order <- nb2nb_order(listw = listw, sf = nc)

# With a sf object (regular lattice: hexagons)
sfc = sf::st_sfc(sf::st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)))))
hexs <- sf::st_make_grid(sfc, cellsize = 0.1, square = FALSE)
hexs.sf <- sf::st_sf(hexs)
listw  <- spdep::poly2nb(as(hexs.sf, "Spatial"), queen = FALSE)
listw.order <- nb2nb_order(listw = listw, sf = hexs.sf)

Run the code above in your browser using DataLab