Filter all observations in a data.frame that fall within a circle of a specified radius drawn around a given latitude and longitude point.
Arguments
- data
data.frame with at least columns for longitude and latitude.
- lon_center
numeric. Representing the longitude of the circle's center.
- lat_center
numeric. Representing the latitude of the circle's center.
- lon
column name in
data
containing longitudes (default islon
).- lat
column name in
data
containing latitudes (default islat
).- radius
radius of the circle in meters (default is 200m).
Value
A subset of the input data.frame containing only the observations that fall within the specified circle.
Examples
points_in_circle(Groningen, lon_center = 6.571561, lat_center = 53.21326,
radius = 60)
#> # A tibble: 3 × 10
#> street number letter suffix postal_code city lon lat amount distance_m
#> <chr> <int> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 Heresing… 5 NA NA 9711EP Gron… 6.57 53.2 5 31.4
#> 2 Heresing… 11 NA NA 9711ER Gron… 6.57 53.2 11 47.8
#> 3 Zuiderpa… 1003 NA NA 9724AK Gron… 6.57 53.2 1003 57.6