This function thins a dataset so that only observations that have a distance from each other greater than "dist_min" are retained.
thin_by_dist(data, dist_min, coords = NULL)
An object of class sf::sf
or data.frame
, the same as "data".
An sf::sf
data frame, or a data frame with coordinate variables.
These can be defined in coords
, unless they have standard names
(see details below).
Minimum distance between points (in units appropriate for the projection, or meters for lonlat data).
A vector of length two giving the names of the "x" and "y"
coordinates, as found in data
. If left to NULL, the function will
try to guess the columns based on standard names c("x", "y")
, c("X","Y")
,
c("longitude", "latitude")
, or c("lon", "lat")
Distances are measured in the appropriate units for the projection used. In case of raw latitude and longitude (e.g. as provided in a data.frame), the crs is set to WGS84, and units are set to meters.
This function is a modified version of the algorithm in spThin
, adapted
to work on sf
objects.