\HeaderA{zerodist}{find point pairs with equal spatial coordinates}{zerodist}
\aliasA{remove.duplicates}{zerodist}{remove.duplicates}
\keyword{dplot}{zerodist}
\begin{Description}\relax
find point pairs with equal spatial coordinates
\end{Description}
\begin{Usage}
\begin{verbatim} 
zerodist(obj, zero = 0.0) 
remove.duplicates(obj, zero = 0.0)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{obj}] object of, or extending, class \LinkA{SpatialPoints}{SpatialPoints} 
\item[\code{zero}] value to be compared to for establishing when a distance
is considered zero (default 0.0) 
\end{ldescription}
\end{Arguments}
\begin{Value}
pairs of row numbers with identical coordinates, numeric(0) if no
such pairs are found
\end{Value}
\begin{Note}\relax
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
\end{Note}
\begin{Examples}
\begin{ExampleCode}
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)
\end{ExampleCode}
\end{Examples}

