nearloc                 package:geoR                 R Documentation

_N_e_a_r _l_o_c_a_t_i_o_n _t_o _a _p_o_i_n_t

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

     For a given set of points and locations identified by 2D
     coordinates this function finds the nearest location of each point

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

     nearloc(points, locations, positions = FALSE)

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

  points: a matrix, data-frame or list with the 2D coordinates of a set
          of points for which you want to find the nearest location.  

locations: a matrix, data-frame or list with the 2D coordinates of a
          set of locations.  

positions: logical defining what to be returned. If 'TRUE' the function
          returns the positions of the locations, otherwise the
          coordinates of the locations. Defaults to 'FALSE'.  

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

     If 'positions = FALSE' the function returns  a matrix, data-frame
     or list of the same type and size as the object provided in the
     argument 'points' with the coordinates of the nearest locations.

     If 'positions = FALSE' the function returns a vector with the
     position of the nearest points in the 'locations' object.

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

     Paulo J. Ribeiro Jr. paulojus@leg.ufpr.br, 
      Peter J. Diggle p.diggle@lancaster.ac.uk.

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

     'loccoords'

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

     set.seed(276)
     gr <- expand.grid(seq(0,1, l=11), seq(0,1, l=11))
     plot(gr, asp=1)
     pts <- matrix(runif(10), nc=2)
     points(pts, pch=19)
     near <- nearloc(points=pts, locations=gr)
     points(near, pch=19, col=2)
     rownames(near)
     nearloc(points=pts, locations=gr, pos=TRUE)

