# [R-sig-Geo] remove points less than certain distance

Bastien.Ferland-Raymond at mrn.gouv.qc.ca Bastien.Ferland-Raymond at mrn.gouv.qc.ca
Mon Apr 29 13:40:27 CEST 2013

```Hello,

I looked at your problem and I can't understand it.  What are your trying to do?  It's not clear.  Are you trying to find the points that are at less than 200m from ALL other points?  Or at 200m of AT LEAST one other point?  You have a distance matrix here, which is n*n, you can difficultly transpose that to your coordinates data frame which is n*2.

Have you thought of using the combination of rgeos::gBuffer() and over()?  Maybe there's something there.

Bastien Ferland-Raymond, M.Sc. Stat., M.Sc. Biol.
Division des orientations et projets spéciaux
Direction des inventaires forestiers
Ministère des Ressources naturelles

# I have a SpatialPointsDataFrame that contains points, some of which are <=200m from each other, some of which points are >200m from each other. x <- c(-1.344, -1.345, -1.346, -1.346,-1.347, -1.328, -1.329, -1.33) y <- c(rep(54.76558, 3), 54.7610, 54.7611, rep(54.75167, 3)) xy <- data.frame(x,y, values=rnorm(8)) xy <- xy[sample(1:8, 8),]
coordinates(xy) <- c("x", "y")
proj4string(xy) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
plot(xy)

# find which points are <= 200m
spDists(xy) <= 0.2

# of the points that are <=200m from each other, I need all but one of those points removed from xy. I should be left with 3 rows in xy. How do I do this?

Thanks
Ross

```