zerodist                 package:sp                 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(obj, zero = 0.0) 
     remove.duplicates(obj, zero = 0.0)

_A_r_g_u_m_e_n_t_s:

     obj: object of, or extending, class SpatialPoints 

    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

_N_o_t_e:

     When using kriging, 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:

     data(meuse)
     summary(meuse)
     # pick 10 rows
     n <- 10
     ran10 <- sample(nrow(meuse), size = n, replace = TRUE)
     meusedup <- rbind(meuse, meuse[ran10, ])
     coordinates(meusedup) <- c("x", "y")
     zd <- zerodist(meusedup)
     sum(abs(zd[1:n,1] - sort(ran10))) # 0!
     # remove the duplicate rows:
     meusedup2 <- meusedup[-zd[,2], ]
     summary(meusedup2)
     meusedup3 <- subset(meusedup, !(1:nrow(meusedup) %in% zd[,2]))
     summary(meusedup3)

