tri2nb                 package:spdep                 R Documentation

_N_e_i_g_h_b_o_u_r_s _l_i_s_t _f_r_o_m _t_r_i _o_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     The function uses the 'deldir' package to convert a matrix of
     two-dimensional coordinates into a neighbours list of class 'nb'
     with a list of integer vectors containing neighbour region number
     ids.

_U_s_a_g_e:

     tri2nb(coords, row.names = NULL)

_A_r_g_u_m_e_n_t_s:

  coords: matrix of point coordinates with two columns

row.names: character vector of region ids to be added to the neighbours
          list as attribute 'region.id', default 'seq(1, nrow(x))'

_D_e_t_a_i_l_s:

     If the coordinates are from a grid, then they need to be ordered
     such that the first three are not collinear, so that the first
     triangle can be constructed. This can be achieved by randomising
     the order of the coordinates (possibly several times), and then
     re-ordering the order of the data to match the new order of the
     neighbour list - if this fix is used, remember to re-order the
     row.names argument as well as the coordinates! Please also note
     that triangulation of grid points will give arbitrary diagonal
     neighbours, which may not be a sensible outcome, and
     'dnearneigh()' may serve better where 'tri2nb()' cannot be used.

_V_a_l_u_e:

     The function returns an object of class 'nb' with a list of
     integer vectors containing neighbour region number ids.

_A_u_t_h_o_r(_s):

     Roger Bivand Roger.Bivand@nhh.no

_S_e_e _A_l_s_o:

     'knn2nb', 'dnearneigh', 'cell2nb'

_E_x_a_m_p_l_e_s:

     example(columbus)
     coords <- coordinates(columbus)
     ind <- sapply(slot(columbus, "polygons"), function(x) slot(x, "ID"))
     col.tri.nb <- tri2nb(coords, row.names=ind)
     plot(columbus, border="grey")
     plot(col.tri.nb, coords, add=TRUE)
     title(main="Raw triangulation links")
     x <- seq(0,1,0.1)
     y <- seq(0,2,0.2)
     xy <- expand.grid(x, y)
     try(xy.nb <- tri2nb(xy))
     seed <- 1234
     xid <- sample(1:nrow(xy))
     xy.nb <- tri2nb(xy[xid,])
     plot(xy.nb, xy[xid,])

