poly2nb                package:spdep                R Documentation

_C_o_n_s_t_r_u_c_t _n_e_i_g_h_b_o_u_r_s _l_i_s_t _f_r_o_m _p_o_l_y_g_o_n _l_i_s_t

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

     The function builds a neighbours list based on regions with
     contiguous boundaries, that is sharing one or more boundary point.
     The current function is in part interpreted and may run slowly for
     many regions or detailed boundaries, but from 0.2-16 should not
     fail because of lack of memory when single polygons are built of
     very many border coordinates.

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

     poly2nb(pl, row.names = NULL, snap=sqrt(.Machine$double.eps),
      queen=TRUE)

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

      pl: list of polygons of class 'polylist', or an object of a class
          extending 'SpatialPolygons'

row.names: character vector of region ids to be added to the neighbours
          list as attribute 'region.id', default 'seq(1, nrow(x))'; if
          'polys' has a 'region.id' attribute, it is copied to the
          neighbours list.

    snap: boundary points less than 'snap' distance apart are
          considered to indicate contiguity

   queen: if TRUE, a single shared boundary point meets the contiguity
          condition, if FALSE, more than one shared point is required

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

     A neighbours list with class 'nb'

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

     Roger Bivand Roger.Bivand@nhh.no

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

     'summary.nb'

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

     example(columbus)
     coords <- coordinates(columbus)
     xx <- poly2nb(columbus)
     dxx <- diffnb(xx, col.gal.nb)
     plot(columbus, border="grey")
     plot(col.gal.nb, coords, add=TRUE)
     plot(dxx, coords, add=TRUE, col="red")
     title(main=paste("Differences (red) in Columbus GAL weights (black)",
      "and polygon generated queen weights", sep="\n"))
     xxx <- poly2nb(columbus, queen=FALSE)
     dxxx <- diffnb(xxx, col.gal.nb)
     plot(columbus, border = "grey")
     plot(col.gal.nb, coords, add = TRUE)
     plot(dxxx, coords, add = TRUE, col = "red")
     title(main=paste("Differences (red) in Columbus GAL weights (black)",
      "and polygon generated rook weights", sep="\n"))
     cards <- card(xx)
     maxconts <- which(cards == max(cards))
     if(length(maxconts) > 1) maxconts <- maxconts[1]
     fg <- rep("grey", length(cards))
     fg[maxconts] <- "red"
     fg[xx[[maxconts]]] <- "green"
     plot(columbus, col=fg)
     title(main="Region with largest number of contiguities")
     example(nc.sids)
     xxnb <- poly2nb(nc.sids)
     plot(nc.sids)
     plot(xxnb, coordinates(nc.sids), add=TRUE, col="blue")

