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

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/nb2nb_order.R

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

1
nb2nb_order(listw = listw, sf = sf)

Arguments

listw

an object of the nb class.

sf

the sf object used to get the listw .

Details

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

Value

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

Author(s)

Fernando López fernando.lopez@upct.es
Román Mínguez roman.minguez@uclm.es
Antonio Páez paez@gmail.com
Manuel Ruiz manuel.ruiz@upct.es

@references

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# With a sf object (irregular lattice)
library(sf)
fname <- system.file("shape/nc.shp", package="sf")
nc <- 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 = st_sfc(st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)))))
hexs <- st_make_grid(sfc, cellsize = 0.1, square = FALSE)
hexs.sf <- st_sf(hexs)
listw  <- poly2nb(as(hexs.sf, "Spatial"), queen = FALSE)
listw.order <- nb2nb_order(listw = listw, sf = hexs.sf)

rominsal/spqdata documentation built on Jan. 24, 2021, 11:11 a.m.