Skip to main content
1 of 3
Jeffrey Evans
  • 32k
  • 2
  • 48
  • 97

I just added a function "sample.distance" to the development version of spatialEco package. You can install the developemnt version from GitHub using: devtools::install_github("jeffreyevans/spatialEco")

Please note that just because you specify a condition for your data does not mean that it can actually be met. Here is an example using the simple meuse data. The problem cannot meet the condition of a 500m minimum sampling distance at greater than ~15 points (n for 50% sample is 78). I added error checking for non-convergence and the function will return the subsample on however many samples can be identified using the given conditions.

library(sp)
library(spatialEco)
data(meuse)
  coordinates(meuse) <- ~ x+y

p = round( nrow(meuse) * 0.50, 0 )
sub.meuse <- sample.distance(meuse, n = p, d = 500, trace = TRUE)  
  plot(meuse,pch=19, main="min dist = 500")
    points(sub.meuse, pch=19, col="red") 

If you end up using this function in your research, please cite the package.

Jeffrey Evans
  • 32k
  • 2
  • 48
  • 97