points_in_circle: Find points within a circle around a center coordinate
Description
This function selects rows from a data frame whose
longitude/latitude coordinates fall within a given radius (in meters) from a
specified center point. It also calculates the distance of each point to the
center.
Usage
points_in_circle(
data,
lon_center,
lat_center,
lon = lon,
lat = lat,
radius = 200,
sort = TRUE
)
Value
A data frame subset of data with an extra column
distance_m giving the distance to the center point.
Arguments
data
A data frame containing at least longitude and latitude columns.
lon_center
Numeric scalar, longitude of the circle center.
lat_center
Numeric scalar, latitude of the circle center.
lon
Name of the longitude column in data.
lat
Name of the latitude column in data.
radius
Numeric, circle radius in meters. Default is 200.
sort
Logical, if TRUE (default) results are sorted by distance
from the center (closest first). If FALSE, the order of data
is preserved.