Skip to content
Prev 361824 / 398506 Next

Excluding coordinates that fall within a circle

Use the first argument of the "[" function to select rows that meet your requirement. I constructed values in hte unit square and select only items in hte corners by excluding values within 0.5 units of the center, (0.5,0.5)


dfrm <- data.frame(ID=1:100, lat=runif(100), long=runif(100), 
                   Datetime=as.POSIXct(runif(100)*10000,origin="1970-01-01") )
reduced <- dfrm[ (dfrm$lat - .5)^2+(dfrm$long-.5)^2 > .25 , ]
with( reduced, plot(lat,long) )

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplot.pdf
Type: application/pdf
Size: 90150 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160617/a96d318d/attachment.pdf>
-------------- next part --------------


Probably should have plotted (long, lat), and it might have been more eser freindly to use subset instead of `[ logical-vector, ]`  but I think this demonstrates the essential steps.