[R] Excluding coordinates that fall within a circle

Tom Wright tom at maladmin.com
Fri Jun 17 20:15:42 CEST 2016


I'm no expert here but I have recently been playing with the package
'geosphere' it contains plenty of options to calculate distance
between two coordinates specified as lat and long.

install.packages('geosphere') # only needed once

library(geosphere)
coord1 <- c(43.60923,-79.322799)
coord2 <- c(43.683266,-79.323703)

distHaversine(coord1,coord2)

Once you have a vector of distances you can then filter your df

df <- df[df$distance < radius,]

On Fri, Jun 17, 2016 at 1:26 PM, 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
>
> Any suggestions would be greatly appreciated.
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list