Message-ID: <5D46931F-978F-47CA-B39D-8864FCFE7055@comcast.net>
Date: 2016-06-17T18:09:38Z
From: David Winsemius
Subject: Excluding coordinates that fall within a circle
In-Reply-To: <1628514766.23197020.1466184392035.JavaMail.zimbra@sfu.ca>
> On Jun 17, 2016, at 10:26 AM, Alice Domalik <adomalik at sfu.ca> wrote:
>
> Hi List,
>
> I'm working with some bird tracking data, and to filter the data set, I need to exclude points taken at the colony.
> I would like to exclude coordinates from within a 500 meter radius of a point centered on the colony.
> However, as an R novice, I'm not sure how to accomplish this.
>
> My df looks like this:
>
> AnimalID Latitude Longitude Datetime
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.
--
David Winsemius
Alameda, CA, USA