mask_donut: Mask coordinates using donut pertubation

View source: R/mask_donut.R

mask_donutR Documentation

Mask coordinates using donut pertubation

Description

Perturbs points with a uniform perturbation in a donut. Note that r_min r_max can either be one distance, or a distance per data point.

Usage

mask_donut(x, r_min, r_max, plot = FALSE)

Arguments

x

coordinates, matrix or data.frame (first two columns)

r_min

numeric min perturbation distance (vectorized)

r_max

numeric min perturbation distance (vectorized)

plot

if TRUE points will be plotted.

Value

adapted x with perturbed coordinates

Examples

x <- cbind(
  x = c(2.5, 3.5, 7.2, 1.5),
  y = c(6.2, 3.8, 4.4, 2.1)
)

# plotting is only useful from small datasets!

# grid masking
x_g <- mask_grid(x, r=1, plot=TRUE)

# random pertubation
set.seed(3)
x_r <- mask_random(x, r=1, plot=TRUE)

x_d <- mask_donut(x, r_min=1, r_max=2, plot=TRUE)



  if (requireNamespace("FNN", quietly = TRUE)){
    # weighted random pertubation
    x_wr <- mask_weighted_random(x, k = 2, r = 4, plot=TRUE)
  }

  if ( requireNamespace("FNN", quietly = TRUE)
    && requireNamespace("sf", quietly = TRUE)
     ){
    # voronoi masking, plotting needs package `sf`
    x_vor <- mask_voronoi(x, r = 1, plot=TRUE)
  }


edwindj/sdcSpatial documentation built on April 13, 2025, 1:57 a.m.