EVOLUTION-MANAGER
Edit File: zerodist.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: find point pairs with equal spatial coordinates</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for zerodist {sp}"><tr><td>zerodist {sp}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> find point pairs with equal spatial coordinates </h2> <h3>Description</h3> <p> find point pairs with equal spatial coordinates </p> <h3>Usage</h3> <pre> zerodist(obj, zero = 0.0, unique.ID = FALSE, memcmp = TRUE) zerodist2(obj1, obj2, zero = 0.0, memcmp = TRUE) remove.duplicates(obj, zero = 0.0, remove.second = TRUE, memcmp = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>obj</code></td> <td> <p> object of, or extending, class <a href="SpatialPoints.html">SpatialPoints</a> </p> </td></tr> <tr valign="top"><td><code>obj1</code></td> <td> <p> object of, or extending, class <a href="SpatialPoints.html">SpatialPoints</a> </p> </td></tr> <tr valign="top"><td><code>obj2</code></td> <td> <p> object of, or extending, class <a href="SpatialPoints.html">SpatialPoints</a> </p> </td></tr> <tr valign="top"><td><code>zero</code></td> <td> <p> distance values less than or equal to this threshold value are considered to have zero distance (default 0.0); units are those of the coordinates for projected data or unknown projection, or km if coordinates are defined to be longitude/latitude </p> </td></tr> <tr valign="top"><td><code>unique.ID</code></td> <td> <p>logical; if TRUE, return an ID (integer) for each point that is different only when two points do not share the same location </p> </td></tr> <tr valign="top"><td><code>memcmp</code></td> <td> <p>use <code>memcmp</code> to find exactly equal coordinates; see NOTE</p> </td></tr> <tr valign="top"><td><code>remove.second</code></td> <td> <p>logical; if TRUE, the second of each pair of duplicate points is removed, if FALSE remove the first</p> </td></tr> </table> <h3>Value</h3> <p><code>zerodist</code> and <code>zerodist2</code> return a two-column matrix with in each row pairs of row numbers with identical coordinates; a matrix with zero rows is returned if no such pairs are found. For <code>zerodist</code>, row number pairs refer to row pairs in <code>obj</code>. For <code>zerodist2</code>, row number pairs refer to rows in <code>obj</code> and <code>obj2</code>, respectively. <code>remove.duplicates</code> removes duplicate observations if present, and else returns <code>obj</code>. </p> <h3>Note</h3> <p> When using kriging, duplicate observations sharing identical spatial locations result in singular covariance matrices. This function may help identify and remove spatial duplices. The full matrix with all pair-wise distances is not stored; the double loop is done at the C level. </p> <p>When <code>unique.ID=TRUE</code> is used, an integer index is returned. sp 1.0-14 returned the highest index, sp 1.0-15 and later return the lowest index. </p> <p>When <code>zero</code> is 0.0 and <code>memcmp</code> is not <code>FALSE</code>, <code>zerodist</code> uses <code>memcmp</code> to evaluate exact equality of coordinates; there may be cases where this results in a different evaluation compared to doing the double arithmetic of computing distances. </p> <h3>Examples</h3> <pre> 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) coordinates(meuse) <- c("x", "y") zerodist2(meuse, meuse[c(10:33,1,10),]) </pre> <hr /><div style="text-align: center;">[Package <em>sp</em> version 1.4-2 <a href="00Index.html">Index</a>]</div> </body></html>