keep_farthest: Find and keep the points farthest from each other

View source: R/balance_around.R

keep_farthestR Documentation

Find and keep the points farthest from each other

Description

This will take a set of existing points and new points and combine them to create a set consisting of the existing points and the farthest new points. The original intended use case was to take a collection of sampling locations from one or more sample designs (existing_points) and use them as part of a new, spatially balanced sample design. The function takes a set of new, random, spatially balanced points (new_points) and determines the distance between each of them and each of the existing points. It then sequentially eliminates the new point closest to any existing point until the combined number of existing points and remaining points is equal to target.

Usage

keep_farthest(
  existing_points,
  new_points,
  target = NULL,
  projection = "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0",
  verbose = FALSE
)

Arguments

existing_points

Point sf object. These are the points that will all be included in the output points and the points against which new_points will be compared against.

new_points

Point sf object. These are the points that may be included in the output. The number that will be is equal to target - nrow(existing_points).

target

Numeric value. The total number of points to include in the output. Defaults to nrow(new_points) - nrow(existing_points).

projection

Character string. The projection to force all spatial objects into. Defaults to NAD83, "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0".

verbose

Logical value. If TRUE then additional diagnostic messages will be produced while the function runs. Defaults to FALSE.

Value

A point sf object containing all the points from existing_points and target - nrow(existing_points) points from new_points using the CRS specified in projection. It will only have those variables that were in common between both existing_points and new_points.


nstauffer/sample.design documentation built on May 9, 2022, 3:21 a.m.