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

Tim Howard tghoward at gw.dec.state.ny.us
Mon Apr 29 13:26:31 CEST 2013


Try the function zerodist or remove.duplicates in sp, with zero set to 0.2
 
Cheers, 
Tim
 

>>>>>>>>>>>
Date: Fri, 26 Apr 2013 15:10:57 +0100
From: Ross Ahmed <rossahmed at googlemail.com>
To: <r-sig-geo at r-project.org>
Subject: [R-sig-Geo] remove points less than certain distance
Message-ID: <CDA04981.4A46%rossahmed at gmail.com>
Content-Type: text/plain

# 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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130429/c94ebccc/attachment.html>


More information about the R-sig-Geo mailing list