zerodist                package:gstat                R Documentation

_f_i_n_d _p_o_i_n_t _p_a_i_r_s _w_i_t_h _e_q_u_a_l _s_p_a_t_i_a_l _c_o_o_r_d_i_n_a_t_e_s

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

     find point pairs with equal spatial coordinates

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

      zerodist(x, y, z, zero = 0.0) 

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

       x: vector with x-coordinate 

       y: vector with y-coordinate (may be missing) 

       z: vector with z-coordinate (may be missing) 

    zero: value to be compared to for establishing when a distance is
          considered zero (default 0.0) 

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

     pairs of row numbers with identical coordinates, numeric(0) if no
     such pairs are found; if zero is set to a positive value, the
     distance between point pairs is returned in the third column.

_N_o_t_e:

     Duplicate observations sharing identical spatial locations result
     in singular covariance matrices in kriging situations. This
     function may help identifying spatial duplications, so they can be
     removed.  A matrix with all pair-wise distances is calculated, so
     if x, y and z are large this function is slow

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

     if (require(sp) == FALSE) {
     data(meuse)
     # pick 10 rows
     n <- 10
     ran10 <- sample(nrow(meuse), size = n, replace = TRUE)
     meusedup <- rbind(meuse, meuse[ran10, ])
     zerodist(meusedup$x, meusedup$y)
     zd <- zerodist(meusedup$x, meusedup$y)
     sum(abs(zd[1:n,1] - sort(ran10))) # 0!
     # remove the duplicate rows:
     meusedup2 <- meusedup[-zd[,2], ]
     # find point pairs within 500 m distance of each other:
     zerodist(meuse$x, meuse$y, 500)
     }

