points_in_circle: Find points within a circle around a center coordinate

View source: R/points_in_circle.R

points_in_circleR Documentation

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
)

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.

Value

A data frame subset of data with an extra column distance_m giving the distance to the center point.

Author(s)

Martin Haringa

Examples

points_in_circle(Groningen, lon_center = 6.571561, lat_center = 53.21326,
radius = 60)


spatialrisk documentation built on Sept. 14, 2025, 5:08 p.m.